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 if (localStorage.currentVersion) |
58 seenDataCorruption = true; | 73 seenDataCorruption = true; |
59 delete localStorage.currentVersion; | 74 delete localStorage.currentVersion; |
60 callback(null); | 75 callback(null); |
61 return; | 76 return; |
62 } | 77 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 { | 177 { |
163 fileEntry.remove(function() | 178 fileEntry.remove(function() |
164 { | 179 { |
165 callback(null); | 180 callback(null); |
166 }, callback); | 181 }, callback); |
167 }, callback); | 182 }, callback); |
168 }, | 183 }, |
169 | 184 |
170 statFile: function(file, callback) | 185 statFile: function(file, callback) |
171 { | 186 { |
| 187 // Hack to allow importing old data |
| 188 if (typeof file == "string") |
| 189 { |
| 190 var Utils = require("utils").Utils; |
| 191 Utils.runAsync(callback.bind(null, null, { |
| 192 exists: true, |
| 193 isDirectory: false, |
| 194 isFile: true, |
| 195 lastModified: 0 |
| 196 })); |
| 197 return; |
| 198 } |
| 199 |
172 this._getFileEntry(file, false, function(fs, fileEntry) | 200 this._getFileEntry(file, false, function(fs, fileEntry) |
173 { | 201 { |
174 fileEntry.getMetadata(function(metadata) | 202 fileEntry.getMetadata(function(metadata) |
175 { | 203 { |
176 callback(null, { | 204 callback(null, { |
177 exists: true, | 205 exists: true, |
178 isDirectory: fileEntry.isDirectory, | 206 isDirectory: fileEntry.isDirectory, |
179 isFile: fileEntry.isFile, | 207 isFile: fileEntry.isFile, |
180 lastModified: metadata.modificationTime.getTime() | 208 lastModified: metadata.modificationTime.getTime() |
181 }); | 209 }); |
182 }, callback); | 210 }, callback); |
183 }, callback); | 211 }, callback); |
184 } | 212 } |
185 }; | 213 }; |
OLD | NEW |