Index: lib/io.js |
=================================================================== |
--- a/lib/io.js |
+++ b/lib/io.js |
@@ -28,32 +28,22 @@ |
{ |
return new Promise((resolve, reject) => |
{ |
- let key = fileToKey(fileName); |
- |
- ext.storage.get(key, items => |
+ localforage.getItem(fileToKey(fileName), (err, value) => |
{ |
- let entry = items[key]; |
- |
- if (entry) |
- resolve(entry); |
+ if (err || value == null) |
+ reject({type: "NoSuchFile"}); |
else |
- reject({type: "NoSuchFile"}); |
+ resolve(value); |
}); |
}); |
} |
function saveFile(fileName, data) |
{ |
- return new Promise((resolve, reject) => |
- { |
- ext.storage.set( |
- fileToKey(fileName), |
- { |
- content: Array.from(data), |
- lastModified: Date.now() |
- }, |
- resolve |
- ); |
+ let key = fileToKey(fileName); |
+ return localforage.setItem(key, { |
+ content: Array.from(data), |
+ lastModified: Date.now() |
}); |
} |
@@ -133,16 +123,7 @@ |
{ |
return loadFile(fromFile).then(entry => |
{ |
- return new Promise((resolve, reject) => |
- { |
- ext.storage.set(fileToKey(newName), entry, () => |
- { |
- if (chrome.runtime.lastError) |
- reject(chrome.runtime.lastError.message); |
- else |
- resolve(); |
- }); |
- }); |
+ return saveFile(fileToKey(newName), entry); |
}).then(() => removeFile(fromFile)); |
}, |