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

Side by Side Diff: lib/io.js

Issue 29453555: Issue 5285 - Fix saving filters on clean Thunderbird or SeaMonkey profiles (Closed) Base URL: https://hg.adblockplus.org/adblockplus
Patch Set: Created June 1, 2017, 9:15 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 }); 69 });
70 } 70 }
71 71
72 function legacyFile(fileName) 72 function legacyFile(fileName)
73 { 73 {
74 let file = LegacyIO.resolveFilePath("adblockplus"); 74 let file = LegacyIO.resolveFilePath("adblockplus");
75 file.append(fileName); 75 file.append(fileName);
76 return file; 76 return file;
77 } 77 }
78 78
79 function ensureDirExists(file)
80 {
81 if (!file.exists())
82 {
83 ensureDirExists(file.parent);
84 file.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
85 }
86 }
87
79 let fallback = { 88 let fallback = {
80 readFromFile(fileName, listener) 89 readFromFile(fileName, listener)
81 { 90 {
82 let wrapper = { 91 let wrapper = {
83 process(line) 92 process(line)
84 { 93 {
85 if (line !== null) 94 if (line !== null)
86 listener(line); 95 listener(line);
87 } 96 }
88 }; 97 };
89 return callLegacy("readFromFile", legacyFile(fileName), wrapper); 98 return callLegacy("readFromFile", legacyFile(fileName), wrapper);
90 }, 99 },
91 100
92 writeToFile(fileName, data) 101 writeToFile(fileName, data)
93 { 102 {
94 return callLegacy("writeToFile", legacyFile(fileName), data); 103 let file = legacyFile(fileName);
104 ensureDirExists(file.parent);
Wladimir Palant 2017/06/01 09:16:41 For reference, this operation was originally being
105 return callLegacy("writeToFile", file, data);
95 }, 106 },
96 107
97 copyFile(fromFile, toFile) 108 copyFile(fromFile, toFile)
98 { 109 {
99 return callLegacy("copyFile", legacyFile(fromFile), legacyFile(toFile)); 110 return callLegacy("copyFile", legacyFile(fromFile), legacyFile(toFile));
100 }, 111 },
101 112
102 renameFile(fromFile, newName) 113 renameFile(fromFile, newName)
103 { 114 {
104 return callLegacy("renameFile", legacyFile(fromFile), newName); 115 return callLegacy("renameFile", legacyFile(fromFile), newName);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 { 270 {
260 return method(...args).catch(error => 271 return method(...args).catch(error =>
261 { 272 {
262 if (error == "NoSuchFile") 273 if (error == "NoSuchFile")
263 return fallbackMethod(...args); 274 return fallbackMethod(...args);
264 throw error; 275 throw error;
265 }); 276 });
266 }; 277 };
267 } 278 }
268 } 279 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld