Handle quota exceeded messages better

Former-commit-id: e1db4679c7413a3c413d4b7d6adfe6bc372cec80 [formerly a200e3821a06d78b17ccd2a4cadd88103ad9fc7c]
Former-commit-id: d8d1e7d9f7ee04c87a821becb18c3861955d6a3b
This commit is contained in:
Jaifroid 2019-08-19 16:08:11 +01:00
parent 4d3795fddf
commit 9592f26378
2 changed files with 15 additions and 3 deletions

View File

@ -50,4 +50,4 @@ display buttons that let you pick the file or the file's folder.
Alternatively, you can download files from http://wiki.kiwix.org/wiki/Content_in_all_languages on a regular
PC. The single non-indexed ZIM files work best. However, if you plan to store your ZIM file on an SD card
formatted as FAT32, you will only be able to use the split files (.zimaa, .zimab, etc.) in the pre-indexed
archives. If your SD card is formatted as exFAT or NTFS, you can use either, but single file is easiest.
archives. If your SD card is formatted as exFAT or NTFS, you can use either, but single file is easiest.

View File

@ -2561,13 +2561,25 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
if (params.rememberLastPage) {
cookies.setItem('lastPageVisit', params.lastPageVisit, Infinity);
//Store current document's raw HTML in localStorage for fast restart
if (typeof Storage !== "undefined") {
if ('localStorage' in window && window['localStorage'] !== null) {
try {
// Ensure we don't go over quota
localStorage.removeItem('lastPageHTML');
localStorage.setItem('lastPageHTML', htmlArticle);
} catch (err) {
console.log("localStorage not supported: " + err);
if (/quota\s*exceeded/i.test(err.message)) {
// Note that Edge gives a quotaExceeded message when running from localhost even if the quota isn't exceeded
// Basically, it means localStorage is not supported in Edge running from localhost...
if (params.cookieSupport == 'local_storage') {
uiUtil.systemAlert('Your localStorage has exceeded its quota, so we are forced to clear it.\n' +
'Because your browser is using localStorage for remembering your settings, these may\n' +
'have been reset. Next time the app launches, please go to Config and set them again.');
}
console.log('Clearing localStorage because quota was exceeded...');
localStorage.clear();
} else {
console.error("Something went wrong with localStorage: ", err);
}
}
}
params.lastPageHTML = htmlArticle;