diff --git a/src/addon/mod/scorm/providers/prefetch-handler.ts b/src/addon/mod/scorm/providers/prefetch-handler.ts index dd34b8fe1..376329f9d 100644 --- a/src/addon/mod/scorm/providers/prefetch-handler.ts +++ b/src/addon/mod/scorm/providers/prefetch-handler.ts @@ -424,17 +424,15 @@ export class AddonModScormPrefetchHandler extends CoreCourseActivityPrefetchHand // Remove the unzipped folder. promises.push(this.fileProvider.removeDir(path).catch((error) => { - if (error && error.code == 1) { + if (error && (error.code == 1 || !this.appProvider.isMobile())) { // Not found, ignore error. } else { return Promise.reject(error); } })); - // Maybe the ZIP wasn't deleted for some reason. Try to delete it too. - promises.push(this.filepoolProvider.removeFileByUrl(siteId, this.scormProvider.getPackageUrl(scorm)).catch(() => { - // Ignore errors. - })); + // Delete other files. + promises.push(this.filepoolProvider.removeFilesByComponent(siteId, this.component, module.id)); return Promise.all(promises); }); diff --git a/src/core/course/providers/module-prefetch-delegate.ts b/src/core/course/providers/module-prefetch-delegate.ts index 888725bce..81c988081 100644 --- a/src/core/course/providers/module-prefetch-delegate.ts +++ b/src/core/course/providers/module-prefetch-delegate.ts @@ -1384,13 +1384,22 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate { } return promise.then(() => { - if (handler) { - // Update status of the module. - const packageId = this.filepoolProvider.getPackageId(handler.component, module.id); - this.statusCache.setValue(packageId, 'downloadedSize', 0); + if (!handler) { + return; + } + + // Update downloaded size. + const packageId = this.filepoolProvider.getPackageId(handler.component, module.id); + this.statusCache.setValue(packageId, 'downloadedSize', 0); + + // If module is downloadable, set not dowloaded status. + return this.isModuleDownloadable(module, courseId).then((downloadable) => { + if (!downloadable) { + return; + } return this.filepoolProvider.storePackageStatus(siteId, CoreConstants.NOT_DOWNLOADED, handler.component, module.id); - } + }); }); }