Index: lib/io.js |
=================================================================== |
--- a/lib/io.js |
+++ b/lib/io.js |
@@ -28,32 +28,23 @@ |
{ |
return new Promise((resolve, reject) => |
{ |
- let key = fileToKey(fileName); |
- |
- ext.storage.get(key, items => |
+ console.trace(); |
Sebastian Noack
2017/08/24 17:11:00
Did you forget to remove this?
Oleksandr
2017/08/24 17:17:04
Whoops. Yes, sorry. Some of the refreshes before c
|
+ 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 +124,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)); |
}, |