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

Unified Diff: lib/filesystem/io.js

Issue 5923900886089728: Use FileSystem API to store data in Opera (Closed)
Patch Set: Prevent first-run page from appearing Created Nov. 26, 2013, 8:48 a.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 | « background.js ('k') | lib/localstorage/io.js » ('j') | lib/websql/io.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « background.js ('k') | lib/localstorage/io.js » ('j') | lib/websql/io.js » ('J')

Powered by Google App Engine
This is Rietveld