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

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

Issue 29355392: Issue 4485 - Clear cache directory (Closed)
Patch Set: Adding null check for listFiles Created Sept. 30, 2016, 3:02 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 | « no previous file | src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | src/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld