Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/io.js

Issue 29526591: Issue 5562 - Move Edge storage to IndexedDB (Closed)
Patch Set: Improve list loading logic and remove redundant checks Created Aug. 24, 2017, 4:47 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/localforage.min.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
},
« no previous file with comments | « no previous file | lib/localforage.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld