aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlan Kligman <ack@mozilla.com>2013-04-24 15:24:00 -0400
committerAlan Kligman <ack@mozilla.com>2013-04-25 00:58:26 -0400
commit608c5d725f8f96134f1cc8fde8d85e79d8be2065 (patch)
tree9c1bf335a9ecbbea0fd61cb6f03e2ce37cca5cf3 /tools
parent9589a2859e3632962bf8a69a8dd5cb2ddc6e2981 (diff)
Fix incorrect cache logic (probably copy pasta error). Add Module.preloadResults to store preload stats (for testing purposes).
Diffstat (limited to 'tools')
-rw-r--r--tools/file_packager.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 892f064f..5f862d36 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -381,10 +381,11 @@ if has_preloaded:
var IDB_RO = "readonly";
var IDB_RW = "readwrite";
var DB_NAME = 'EM_PRELOAD_CACHE';
+ var DB_VERSION = 1;
var METADATA_STORE_NAME = 'METADATA';
var PACKAGE_STORE_NAME = 'PACKAGES';
function openDatabase(callback, errback) {
- var openRequest = indexedDB.open(DB_NAME);
+ var openRequest = indexedDB.open(DB_NAME, DB_VERSION);
openRequest.onupgradeneeded = function(event) {
var db = event.target.result;
@@ -454,7 +455,7 @@ if has_preloaded:
var transaction = db.transaction([PACKAGE_STORE_NAME, METADATA_STORE_NAME], IDB_RW);
var packages = transaction.objectStore(PACKAGE_STORE_NAME);
var metadata = transaction.objectStore(METADATA_STORE_NAME);
-
+console.log(packageData, packageName);
var putPackageRequest = packages.put(packageData, packageName);
putPackageRequest.onsuccess = function(event) {
var putMetadataRequest = metadata.put(packageMeta, packageName);
@@ -530,17 +531,17 @@ if has_preloaded:
if use_preload_cache:
code += r'''
+ if (!Module.preloadResults)
+ Module.preloadResults = {};
+
openDatabase(
function(db) {
checkCachedPackage(db, PACKAGE_NAME,
function(useCached) {
+ Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached};
if (useCached) {
console.info('loading ' + PACKAGE_NAME + ' from cache');
- fetchCachedPackage(db, PACKAGE_NAME,
- function(packageData, packageMeta) {
- cacheRemotePackage(db, packageData, packageMeta, processPackageData, handleError);
- }
- , handleError);
+ fetchCachedPackage(db, PACKAGE_NAME, processPackageData, handleError);
} else {
console.info('loading ' + PACKAGE_NAME + ' from remote');
fetchRemotePackage(REMOTE_PACKAGE_NAME,