Fix autoreload failure when appcache is not available

This commit is contained in:
Kovid Goyal 2019-10-01 10:07:21 +05:30
parent b23b1adcf1
commit 3274ecfa83
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -53,8 +53,9 @@ class Watcher:
def reload_app(self):
appcache = window.top.applicationCache
for which in 'cached error noupdate obsolete updateready'.split(' '):
appcache.addEventListener(which, self.cache_update_done, False)
if appcache:
for which in 'cached error noupdate obsolete updateready'.split(' '):
appcache.addEventListener(which, self.cache_update_done, False)
try:
appcache.update()
except: # In chrome with devtools open, appcache is sometimes disabled/fails
@ -62,7 +63,7 @@ class Watcher:
def cache_update_done(self):
appcache = window.top.applicationCache
if appcache.status is appcache.UPDATEREADY:
if appcache and appcache.status is appcache.UPDATEREADY:
appcache.swapCache()
window.location.reload(True)