diff --git a/www/js/app.js b/www/js/app.js index a9c05ad9..af89869b 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1353,8 +1353,13 @@ archiveFilesLegacy.addEventListener('change', function (files) { console.error('Unable to import files to OPFS!', err); var message = '

We could not import the selected files to the OPFS!

Reason: ' + err.message + '

'; if (/iOS/.test(params.appType) || /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) message = '

Unfortunately, Safari and iOS browsers do not currently support importing files into the OPFS. Please disable the OPFS and use other file selection options.

Error message: ' + err.message + '

'; - uiUtil.systemAlert(message, 'OPFS import error'); uiUtil.pollOpsPanel(); + uiUtil.systemAlert(message, 'OPFS import error').then(function () { + // Delete each of the files that failed to import + filesArray.forEach(function (file) { + cache.deleteOPFSEntry(file.name); + }); + }); }); }); } diff --git a/www/js/lib/kiwixServe.js b/www/js/lib/kiwixServe.js index ed705b30..77677ee6 100644 --- a/www/js/lib/kiwixServe.js +++ b/www/js/lib/kiwixServe.js @@ -629,7 +629,9 @@ function requestXhttpData (URL, lang, subj, kiwixDate) { percentageComplete = 0; var message = 'Unable to download the archive ' + archiveName + ' to your device: ' + err; if (/iOS/.test(params.appType) || /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) message = '

Unfortunately, Safari and iOS browsers do not currently support downloading files directly into the OPFS. Please select a different download method.

Error message: ' + err.message + '

'; - return uiUtil.systemAlert(message, 'Download failed'); + return uiUtil.systemAlert(message, 'Download failed').then(function () { + return cache.deleteOPFSEntry(archiveName); + }); }); } if (megabytes > 1000) {