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

Unified Diff: src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java

Issue 29372653: Issue 4813 - UTFDataFormatException while serializing filter (Closed)
Patch Set: Including UTF-8 constant and adding migration/file corruption recovery logic Created March 9, 2017, 7:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld