 Issue 5923900886089728:
  Use FileSystem API to store data in Opera  (Closed)
    
  
    Issue 5923900886089728:
  Use FileSystem API to store data in Opera  (Closed) 
  | Index: lib/filesystem/io.js | 
| =================================================================== | 
| --- a/lib/filesystem/io.js | 
| +++ b/lib/filesystem/io.js | 
| @@ -45,24 +45,42 @@ var IO = exports.IO = | 
| resolveFilePath: function(path) | 
| { | 
| return new FakeFile(path); | 
| }, | 
| readFromFile: function(file, decode, listener, callback, timeLineID) | 
| { | 
| + // Hack to allow importing old data | 
| + if (typeof file == "string") | 
| + { | 
| + var Utils = require("utils").Utils; | 
| + Utils.runAsync(function() | 
| + { | 
| + var lines = file.split(/[\r\n]+/); | 
| + for (var i = 0; i < lines.length; i++) | 
| + listener.process(lines[i]); | 
| + listener.process(null); | 
| + callback(null); | 
| + }.bind(this)); | 
| + return; | 
| + } | 
| + | 
| if ("spec" in file && /^defaults\b/.test(file.spec)) | 
| { | 
| // Code attempts to read the default patterns.ini, we don't have that. | 
| // Make sure to execute first-run actions instead. | 
| - if (localStorage.currentVersion) | 
| - seenDataCorruption = true; | 
| - delete localStorage.currentVersion; | 
| - callback(null); | 
| + var Utils = require("utils").Utils; | 
| + Utils.runAsync(function() | 
| + { | 
| + if (localStorage.currentVersion) | 
| + seenDataCorruption = true; | 
| + callback(null) | 
| 
Thomas Greiner
2013/11/26 10:23:32
nit: semicolon missing
 | 
| + }); | 
| return; | 
| } | 
| this._getFileEntry(file, false, function(fs, fileEntry) | 
| { | 
| fileEntry.file(function(file) | 
| { | 
| var reader = new FileReader(); | 
| @@ -164,16 +182,29 @@ var IO = exports.IO = | 
| { | 
| callback(null); | 
| }, callback); | 
| }, callback); | 
| }, | 
| statFile: function(file, callback) | 
| { | 
| + // Hack to allow importing old data | 
| + if (typeof file == "string") | 
| + { | 
| + var Utils = require("utils").Utils; | 
| + Utils.runAsync(callback.bind(null, null, { | 
| + exists: true, | 
| + isDirectory: false, | 
| + isFile: true, | 
| + lastModified: 0 | 
| + })); | 
| + return; | 
| + } | 
| + | 
| this._getFileEntry(file, false, function(fs, fileEntry) | 
| { | 
| fileEntry.getMetadata(function(metadata) | 
| { | 
| callback(null, { | 
| exists: true, | 
| isDirectory: fileEntry.isDirectory, | 
| isFile: fileEntry.isFile, |