Index: lib/adblockplus.js |
=================================================================== |
--- a/lib/adblockplus.js |
+++ b/lib/adblockplus.js |
@@ -365,52 +365,33 @@ |
ext.storage.get([key], function(items) |
{ |
var entry = items[key]; |
- if (!entry) |
- { |
- try |
+ if (entry) |
+ { |
+ resolve(entry); |
+ } |
+ else |
+ { |
+ entry = localforage.getItem(key, function(err, value) |
{ |
- entry = JSON.parse(window.localStorage.getItem(key)); |
- } |
- catch (err) |
- {} |
- } |
- if (entry) |
- { |
- resolve(entry); |
- } |
- else |
- { |
- reject(new Error("File doesn't exist")); |
+ if (err || !value) |
+ reject(new Error("File doesn't exist")); |
+ else |
+ resolve(value); |
+ }); |
} |
}); |
}.bind(this)); |
} |
function saveFile(file, data, callback) |
{ |
- var entry = {}; |
var key = fileToKey(file); |
+ var entry = { |
+ lastModified: Date.now(), |
+ content: data |
+ }; |
- if (typeof browser == "undefined") |
- { |
- entry[key] = { |
- lastModified: Date.now(), |
- content: data |
- }; |
- ext.storage.set(entry, callback); |
- } |
- else |
- { |
- var processedData = LZString.compressToUTF16(JSON.stringify(data)); |
- ext.storage.remove(key); |
- entry[key] = { |
- lastModified: Date.now(), |
- content: processedData, |
- compressed: true |
- }; |
- window.localStorage.setItem(key, JSON.stringify(entry[key])); |
- setTimeout(callback, 0); |
- } |
- callback(); |
+ ext.storage.remove(key); |
+ localforage.setItem(key, entry, callback); |
} |
exports.IO = { |
resolveFilePath: function(path) |
@@ -423,10 +404,6 @@ |
{ |
if ("content" in entry) |
{ |
- if (entry["compressed"]) |
- { |
- entry.content = JSON.parse(LZString.decompressFromUTF16(entry.content)); |
- } |
for (var _loopIndex15 = 0; _loopIndex15 < entry.content.length; ++_loopIndex15) |
{ |
var line = entry.content[_loopIndex15]; |