If import failed, delete file stub(s)

This commit is contained in:
Jaifroid 2023-10-10 08:17:32 +01:00
parent da686212f0
commit 3af9fd1ea3
2 changed files with 9 additions and 2 deletions

View File

@ -1353,8 +1353,13 @@ archiveFilesLegacy.addEventListener('change', function (files) {
console.error('Unable to import files to OPFS!', err);
var message = '<p>We could not import the selected files to the OPFS!</p><p>Reason: ' + err.message + '</p>';
if (/iOS/.test(params.appType) || /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) message = '<p>Unfortunately, Safari and iOS browsers do not currently support importing files into the OPFS. Please disable the OPFS and use other file selection options.</p><p>Error message: ' + err.message + '</p>';
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);
});
});
});
});
}

View File

@ -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 = '<p>Unfortunately, Safari and iOS browsers do not currently support downloading files directly into the OPFS. Please select a different download method.</p><p>Error message: ' + err.message + '</p>';
return uiUtil.systemAlert(message, 'Download failed');
return uiUtil.systemAlert(message, 'Download failed').then(function () {
return cache.deleteOPFSEntry(archiveName);
});
});
}
if (megabytes > 1000) {