Index: src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java |
=================================================================== |
--- a/src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java |
+++ b/src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java |
@@ -166,25 +166,28 @@ final class Subscriptions |
private void writeFile(final File output) throws IOException |
{ |
final HashSet<String> filters = new HashSet<String>(); |
for (final Subscription s : this.subscriptions.values()) |
{ |
if (s.isEnabled()) |
{ |
Log.d(TAG, "Adding filters for '" + s.getId() + "'"); |
- s.clearFilters(); |
s.deserializeFilters(this.getFiltersFile(s)); |
- s.getFilters(filters); |
+ s.copyFilters(filters); |
s.clearFilters(); |
} |
+ if ((!s.isMetaDataValid() || !s.isFiltersValid()) && s.getURL() != null) |
+ { |
+ this.engine.enqueueDownload(s, true); |
+ } |
} |
final BufferedWriter w = new BufferedWriter( |
- new OutputStreamWriter(new FileOutputStream(output), "UTF-8")); |
+ new OutputStreamWriter(new FileOutputStream(output), Engine.CHARSET_UTF_8)); |
try |
{ |
Log.d(TAG, "Writing " + filters.size() + " filters"); |
Engine.writeFilterHeaders(w); |
for (final String filter : filters) |
{ |
w.write(filter); |
w.write('\n'); |
@@ -204,33 +207,35 @@ final class Subscriptions |
this.subscriptions.put(id, sub); |
return sub; |
} |
return this.subscriptions.get(id); |
} |
public static Subscriptions initialize(final Engine engine, final File appFolder, |
final File cacheFolder) |
- throws IOException |
{ |
final Subscriptions subs = new Subscriptions(engine, appFolder, cacheFolder); |
subs.subscriptionFolder.mkdirs(); |
subs.cacheFolder.mkdirs(); |
final File[] files = subs.subscriptionFolder.listFiles(); |
for (File f : files) |
{ |
if (f.getName().endsWith(".sub")) |
{ |
final File metaFile = new File(f.getAbsolutePath() + ".meta"); |
if (metaFile.exists()) |
{ |
final Subscription sub = Subscription.deserializeSubscription(metaFile); |
- subs.subscriptions.put(sub.getId(), sub); |
+ if (sub != null) |
+ { |
+ subs.subscriptions.put(sub.getId(), sub); |
+ } |
} |
} |
} |
subs.createUserSubscriptions(); |
return subs; |
} |