From 40032e7d5fcfa204f7e2aa45c2f59d1a58bf699f Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 22 May 2024 16:19:57 +0200 Subject: [PATCH] MOBILE-4470 course: Delete files linked to course component --- src/core/features/course/services/course-helper.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index dce4f5be3..814db49c1 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -1912,12 +1912,14 @@ export class CoreCourseHelperProvider { * @returns Promise to be resolved once the course files are deleted. */ async deleteCourseFiles(courseId: number): Promise { + const siteId = CoreSites.getCurrentSiteId(); const sections = await CoreCourse.getSections(courseId); const modules = sections.map((section) => section.modules).flat(); - await Promise.all( - modules.map((module) => this.removeModuleStoredData(module, courseId)), - ); + await Promise.all([ + ...modules.map((module) => this.removeModuleStoredData(module, courseId)), + siteId && CoreFilepool.removeFilesByComponent(siteId, CoreCourseProvider.COMPONENT, courseId), + ]); await CoreCourse.setCourseStatus(courseId, DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED); }