| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 lineBreak: "\n", | 44 lineBreak: "\n", |
| 45 | 45 |
| 46 resolveFilePath: function(path) | 46 resolveFilePath: function(path) |
| 47 { | 47 { |
| 48 return new FakeFile(path); | 48 return new FakeFile(path); |
| 49 }, | 49 }, |
| 50 | 50 |
| 51 readFromFile: function(file, decode, listener, callback, timeLineID) | 51 readFromFile: function(file, decode, listener, callback, timeLineID) |
| 52 { | 52 { |
| 53 // Hack to allow importing old data |
| 54 if (typeof file == "string") |
| 55 { |
| 56 var Utils = require("utils").Utils; |
| 57 Utils.runAsync(function() |
| 58 { |
| 59 var lines = file.split(/[\r\n]+/); |
| 60 for (var i = 0; i < lines.length; i++) |
| 61 listener.process(lines[i]); |
| 62 listener.process(null); |
| 63 callback(null); |
| 64 }.bind(this)); |
| 65 return; |
| 66 } |
| 67 |
| 53 if ("spec" in file && /^defaults\b/.test(file.spec)) | 68 if ("spec" in file && /^defaults\b/.test(file.spec)) |
| 54 { | 69 { |
| 55 // Code attempts to read the default patterns.ini, we don't have that. | 70 // Code attempts to read the default patterns.ini, we don't have that. |
| 56 // Make sure to execute first-run actions instead. | 71 // Make sure to execute first-run actions instead. |
| 57 if (localStorage.currentVersion) | 72 var Utils = require("utils").Utils; |
| 58 seenDataCorruption = true; | 73 Utils.runAsync(function() |
| 59 delete localStorage.currentVersion; | 74 { |
| 60 callback(null); | 75 if (localStorage.currentVersion) |
| 76 seenDataCorruption = true; |
| 77 callback(null) |
| 78 }); |
| 61 return; | 79 return; |
| 62 } | 80 } |
| 63 | 81 |
| 64 this._getFileEntry(file, false, function(fs, fileEntry) | 82 this._getFileEntry(file, false, function(fs, fileEntry) |
| 65 { | 83 { |
| 66 fileEntry.file(function(file) | 84 fileEntry.file(function(file) |
| 67 { | 85 { |
| 68 var reader = new FileReader(); | 86 var reader = new FileReader(); |
| 69 reader.onloadend = function() | 87 reader.onloadend = function() |
| 70 { | 88 { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 { | 180 { |
| 163 fileEntry.remove(function() | 181 fileEntry.remove(function() |
| 164 { | 182 { |
| 165 callback(null); | 183 callback(null); |
| 166 }, callback); | 184 }, callback); |
| 167 }, callback); | 185 }, callback); |
| 168 }, | 186 }, |
| 169 | 187 |
| 170 statFile: function(file, callback) | 188 statFile: function(file, callback) |
| 171 { | 189 { |
| 190 // Hack to allow importing old data |
| 191 if (typeof file == "string") |
| 192 { |
| 193 var Utils = require("utils").Utils; |
| 194 Utils.runAsync(callback.bind(null, null, { |
| 195 exists: true, |
| 196 isDirectory: false, |
| 197 isFile: true, |
| 198 lastModified: 0 |
| 199 })); |
| 200 return; |
| 201 } |
| 202 |
| 172 this._getFileEntry(file, false, function(fs, fileEntry) | 203 this._getFileEntry(file, false, function(fs, fileEntry) |
| 173 { | 204 { |
| 174 fileEntry.getMetadata(function(metadata) | 205 fileEntry.getMetadata(function(metadata) |
| 175 { | 206 { |
| 176 callback(null, { | 207 callback(null, { |
| 177 exists: true, | 208 exists: true, |
| 178 isDirectory: fileEntry.isDirectory, | 209 isDirectory: fileEntry.isDirectory, |
| 179 isFile: fileEntry.isFile, | 210 isFile: fileEntry.isFile, |
| 180 lastModified: metadata.modificationTime.getTime() | 211 lastModified: metadata.modificationTime.getTime() |
| 181 }); | 212 }); |
| 182 }, callback); | 213 }, callback); |
| 183 }, callback); | 214 }, callback); |
| 184 } | 215 } |
| 185 }; | 216 }; |
| OLD | NEW |