From 76961c5b522fb7b598a1ec1ae8ae152d0354a635 Mon Sep 17 00:00:00 2001 From: Alan Kligman Date: Thu, 25 Apr 2013 00:53:43 -0400 Subject: If there's a problem, fall back to default non-cache loading from remote. --- tools/file_packager.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tools/file_packager.py') diff --git a/tools/file_packager.py b/tools/file_packager.py index 2ad65499..425995d7 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -526,6 +526,12 @@ if has_preloaded: if use_preload_cache: code += r''' + function preloadFallback(error) { + console.error(error); + console.error('falling back to default preload behavior'); + fetchRemotePackage(REMOTE_PACKAGE_NAME, processPackageData, handleError); + }; + openDatabase( function(db) { checkCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, @@ -533,19 +539,19 @@ if has_preloaded: Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached}; if (useCached) { console.info('loading ' + PACKAGE_NAME + ' from cache'); - fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, processPackageData, handleError); + fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, processPackageData, preloadFallback); } else { console.info('loading ' + PACKAGE_NAME + ' from remote'); fetchRemotePackage(REMOTE_PACKAGE_NAME, function(packageData) { cacheRemotePackage(db, PACKAGE_PATH + PACKAGE_NAME, packageData, {uuid:PACKAGE_UUID}, processPackageData, handleError); } - , handleError); + , preloadFallback); } } - , handleError); + , preloadFallback); } - , handleError); + , preloadFallback); if (Module['setStatus']) Module['setStatus']('Downloading...'); ''' -- cgit v1.2.3-18-g5258