Index: lib/adblockplus.js |
=================================================================== |
--- a/lib/adblockplus.js |
+++ b/lib/adblockplus.js |
@@ -365,52 +365,36 @@ |
ext.storage.get([key], function(items) |
{ |
var entry = items[key]; |
- if (!entry) |
+ if (entry) |
+ { |
+ resolve(entry); |
+ } |
+ else |
{ |
try |
Sebastian Noack
2016/10/05 21:27:32
I think this try-catch block should be removed now
Oleksandr
2016/10/05 21:49:13
Done.
|
{ |
- entry = JSON.parse(window.localStorage.getItem(key)); |
+ entry = localforage.getItem(key, function(err, value) |
+ { |
+ if (err || !value) |
+ reject(new Error("File doesn't exist")); |
+ else |
+ resolve(value); |
+ }); |
} |
catch (err) |
{} |
} |
- if (entry) |
- { |
- resolve(entry); |
- } |
- else |
- { |
- reject(new Error("File doesn't exist")); |
- } |
}); |
}.bind(this)); |
} |
function saveFile(file, data, callback) |
{ |
- var entry = {}; |
var key = fileToKey(file); |
- |
- 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, |
+ { lastModified: Date.now(), content: data }, |
+ callback |
+ ); |
} |
exports.IO = { |
resolveFilePath: function(path) |
@@ -423,10 +407,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]; |