MOBILE-4470 course: Delete files linked to course component

main
Dani Palou 2024-05-22 16:19:57 +02:00
parent 91c56256ed
commit 40032e7d5f
1 changed files with 5 additions and 3 deletions

View File

@ -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);
} }