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: Remove accidental code Created Aug. 24, 2017, 5:15 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,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));
},
« 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