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()(); |
-}); |