MOBILE-4470 course: Delete files linked to course component
parent
91c56256ed
commit
40032e7d5f
|
@ -1912,12 +1912,14 @@ export class CoreCourseHelperProvider {
|
||||||
* @returns Promise to be resolved once the course files are deleted.
|
* @returns Promise to be resolved once the course files are deleted.
|
||||||
*/
|
*/
|
||||||
async deleteCourseFiles(courseId: number): Promise<void> {
|
async deleteCourseFiles(courseId: number): Promise<void> {
|
||||||
|
const siteId = CoreSites.getCurrentSiteId();
|
||||||
const sections = await CoreCourse.getSections(courseId);
|
const sections = await CoreCourse.getSections(courseId);
|
||||||
const modules = sections.map((section) => section.modules).flat();
|
const modules = sections.map((section) => section.modules).flat();
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all([
|
||||||
modules.map((module) => this.removeModuleStoredData(module, courseId)),
|
...modules.map((module) => this.removeModuleStoredData(module, courseId)),
|
||||||
);
|
siteId && CoreFilepool.removeFilesByComponent(siteId, CoreCourseProvider.COMPONENT, courseId),
|
||||||
|
]);
|
||||||
|
|
||||||
await CoreCourse.setCourseStatus(courseId, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED);
|
await CoreCourse.setCourseStatus(courseId, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue