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

Side by Side Diff: lib/firefoxDataCleanup.js

Issue 29526555: Issue 5554 - [webextensions] Adjust data to account for UI limitations (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome
Patch Set: Created Aug. 24, 2017, 9:02 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 | lib/prefs.js » ('j') | lib/prefs.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 "use strict";
19
20 let {Filter, ActiveFilter} = require("filterClasses");
21 let {FilterNotifier} = require("filterNotifier");
22 let {FilterStorage} = require("filterStorage");
23 let {IO} = require("io");
24 let {Prefs} = require("prefs");
25 let {SpecialSubscription} = require("subscriptionClasses");
26
27 Promise.all([FilterNotifier.once("load"), Prefs.untilLoaded]).then(() =>
28 {
29 if (Prefs.data_cleanup_done)
30 return;
31
32 let haveHitCounts = [];
33
34 for (let key in Filter.knownFilters)
35 {
36 let filter = Filter.knownFilters[key];
37 if (!(filter instanceof ActiveFilter))
38 continue;
39
40 if (filter.disabled)
41 {
42 // Enable or replace disabled filters
43 filter.disabled = false;
44
45 for (let subscription of filter.subscriptions)
46 {
47 if (subscription instanceof SpecialSubscription)
48 {
49 while (true)
50 {
51 let position = subscription.filters.indexOf(filter);
52 if (position < 0)
53 break;
54
55 let newFilter = Filter.fromText("! " + filter.text);
56 FilterStorage.removeFilter(filter, subscription, position);
57 FilterStorage.addFilter(newFilter, subscription, position);
58 }
59 }
60 }
61 }
62
63 if (filter.hitCount || filter.lastHit)
64 haveHitCounts.push(filter);
65 }
66
67 // Reset hit statistics on any filters having them
68 FilterStorage.resetHitCounts(haveHitCounts);
69
70 // Remove any existing automatic backups
71 let backups = [];
72 for (let i = 1; i < 100; i++)
73 backups.push(`file:patterns-backup${i}.ini`);
Wladimir Palant 2017/08/24 09:08:09 This is using implementation details of io.js whic
74 return browser.storage.local.remove(backups).then(() =>
Sebastian Noack 2017/08/24 09:42:05 Returning this promise here seems weird. Did you m
Wladimir Palant 2017/08/24 09:57:43 Right, this is merely a left-over from a previous
75 {
76 Prefs.data_cleanup_done = true;
77 });
78 });
OLDNEW
« no previous file with comments | « no previous file | lib/prefs.js » ('j') | lib/prefs.js » ('J')

Powered by Google App Engine
This is Rietveld