Index: src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java |
=================================================================== |
--- a/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java |
+++ b/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java |
@@ -249,16 +249,30 @@ public final class Engine |
{ |
Log.d(TAG, "Writing filters..."); |
final File filterFile = this.subscriptions.createAndWriteFile(); |
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.serviceContext); |
final String key = this.serviceContext.getString(R.string.key_cached_filter_path); |
prefs.edit().putString(key, filterFile.getAbsolutePath()).commit(); |
+ Log.d(TAG, "Cleaning up cache..."); |
+ final File dummyFile = getDummyFilterFile(this.serviceContext); |
+ final File[] cacheDirFiles = getFilterCacheDir(this.serviceContext).listFiles(); |
+ if (cacheDirFiles != null) |
+ { |
+ for (final File file : cacheDirFiles) |
+ { |
+ if (!file.equals(dummyFile) && !file.equals(filterFile)) |
+ { |
+ Log.d(TAG, "Deleting file:" + file); |
+ file.delete(); |
+ } |
+ } |
+ } |
} |
catch (IOException e) |
{ |
Log.e(TAG, "Failed to write filters", e); |
} |
finally |
{ |
this.unlock(); |