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

Unified Diff: lib/io.js

Issue 29332926: Issue 3446 - Remove code migrating prefs and files to chrome.storage (Closed)
Patch Set: Created Dec. 21, 2015, 2:48 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 | « chrome/ext/background.js ('k') | lib/prefs.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
@@ -58,101 +58,61 @@
readFromFile: function(file, listener, callback)
{
- runWhenMigrated(function()
+ function onLoaded(entry)
{
- function onLoaded(entry)
- {
- for (let line of entry.content)
- listener.process(line);
+ for (let line of entry.content)
+ listener.process(line);
- listener.process(null);
- callback(null);
- }
+ listener.process(null);
+ callback(null);
+ }
- loadFile(file, onLoaded, callback);
- });
+ loadFile(file, onLoaded, callback);
},
writeToFile: function(file, data, callback)
{
- runWhenMigrated(function()
- {
- saveFile(file, data, callback);
- });
+ saveFile(file, data, callback);
},
copyFile: function(fromFile, toFile, callback)
{
- runWhenMigrated(function()
+ function onLoaded(entry)
{
- function onLoaded(entry)
- {
- saveFile(toFile, entry.content, callback);
- }
+ saveFile(toFile, entry.content, callback);
+ }
- loadFile(fromFile, onLoaded, callback);
- });
+ loadFile(fromFile, onLoaded, callback);
},
renameFile: function(fromFile, newName, callback)
{
- runWhenMigrated(function()
+ function onLoaded()
{
- function onLoaded()
+ ext.storage.remove(fileToKey(fromFile), function()
{
- ext.storage.remove(fileToKey(fromFile), function()
- {
- ext.storage.set(keyPrefix + newName, entry, callback);
- });
- }
+ ext.storage.set(keyPrefix + newName, entry, callback);
+ });
+ }
- loadFile(fromFile, onLoaded, callback);
- });
+ loadFile(fromFile, onLoaded, callback);
},
removeFile: function(file, callback)
{
- runWhenMigrated(function()
- {
- ext.storage.remove(fileToKey(file), callback);
- });
+ ext.storage.remove(fileToKey(file), callback);
},
statFile: function(file, callback)
{
- runWhenMigrated(function()
+ function onLoaded(entry)
{
- function onLoaded(entry)
- {
- callback(null, {
- exists: true,
- lastModified: entry.lastModified
- });
- }
+ callback(null, {
+ exists: true,
+ lastModified: entry.lastModified
+ });
+ }
- loadFile(file, onLoaded, callback);
- });
+ loadFile(file, onLoaded, callback);
}
};
-
-// Migrate files for users updating from old versions.
-// Defer IO operations until migration is complete.
-// TODO: Remove the migration code after a few releases.
-let migrated = false;
-let deferred = [];
-
-function runWhenMigrated(callback)
-{
- if (migrated)
- callback();
- else
- deferred.push(callback);
-}
-
-ext.storage.migrateFiles(function()
-{
- migrated = true;
-
- while (deferred.length > 0)
- deferred.shift()();
-});
« no previous file with comments | « chrome/ext/background.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld