Ignore swapCache failures

This commit is contained in:
Kovid Goyal 2017-04-12 10:51:02 +05:30
parent 1672ef4f22
commit 8ee6f735d2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -18,9 +18,14 @@ if is_running_in_iframe:
else: else:
window.applicationCache.addEventListener('updateready', def(): window.applicationCache.addEventListener('updateready', def():
if window.applicationCache.status is window.applicationCache.UPDATEREADY: if window.applicationCache.status is window.applicationCache.UPDATEREADY:
window.applicationCache.swapCache() try:
if window.confirm(_('The calibre web application has been updated. Do you want reload the site?')): window.applicationCache.swapCache()
window.location.reload() if window.confirm(_('The calibre web application has been updated. Do you want reload the site?')):
window.location.reload()
except Exception as e:
# For some reason swapCache occassionally fails even though status is UPDATEREADY
print('WARNING: falied to swap applicationCache')
console.log(e)
, False) , False)
script = document.currentScript or document.scripts[0] script = document.currentScript or document.scripts[0]
main_js(script.textContent) main_js(script.textContent)