MOBILE-3523 course: Fix wrong download icon after delete files

main
Dani Palou 2020-11-26 12:24:39 +01:00
parent 95e2fc2a4d
commit baa2a64322
2 changed files with 17 additions and 10 deletions

View File

@ -424,17 +424,15 @@ export class AddonModScormPrefetchHandler extends CoreCourseActivityPrefetchHand
// Remove the unzipped folder. // Remove the unzipped folder.
promises.push(this.fileProvider.removeDir(path).catch((error) => { 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. // Not found, ignore error.
} else { } else {
return Promise.reject(error); return Promise.reject(error);
} }
})); }));
// Maybe the ZIP wasn't deleted for some reason. Try to delete it too. // Delete other files.
promises.push(this.filepoolProvider.removeFileByUrl(siteId, this.scormProvider.getPackageUrl(scorm)).catch(() => { promises.push(this.filepoolProvider.removeFilesByComponent(siteId, this.component, module.id));
// Ignore errors.
}));
return Promise.all(promises); return Promise.all(promises);
}); });

View File

@ -1384,13 +1384,22 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
} }
return promise.then(() => { return promise.then(() => {
if (handler) { if (!handler) {
// Update status of the module. return;
const packageId = this.filepoolProvider.getPackageId(handler.component, module.id); }
this.statusCache.setValue(packageId, 'downloadedSize', 0);
// 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); return this.filepoolProvider.storePackageStatus(siteId, CoreConstants.NOT_DOWNLOADED, handler.component, module.id);
} });
}); });
} }