Skip to content

Commit

Permalink
[plugin updates] Print file names of a cache files which are failed to
Browse files Browse the repository at this point in the history
be deleted to log.
-- Fix 'find-bugs-plugin' check warnings in 'removeAllDataFromCache()'
to prepare a transition to 'find-bugs-plugin:3.0.3'
  • Loading branch information
Antony Mykolaj committed May 2, 2016
1 parent 05d9601 commit db98ee8
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,31 @@ public boolean removeDataFromCache(Object cacheKey) {

@Override
public void removeAllDataFromCache() {
File cacheFolder = getCacheFolder();
File[] cacheFileList = cacheFolder.listFiles(new FileFilter() {
File folder = getCacheFolder();
if (folder == null) {
Ln.d("Skip 'removeAllDataFromCache' operation. Cache folder is 'null', so there's"
+ " nothing to remove.");
return;
}
File[] cacheFileList = folder.listFiles(new FileFilter() {

@Override
public boolean accept(File file) {
return file.getName().startsWith(getCachePrefix());
}
});

boolean allDeleted = true;
for (File cacheFile : cacheFileList) {
allDeleted = cacheFile.delete() && allDeleted;
if (cacheFileList == null) {
Ln.d("Cache is already clear.");
return;
}
if (allDeleted || cacheFileList.length == 0) {
Ln.d("Some file could not be deleted from cache.");
for (File cacheFile : cacheFileList) {
// Calm down the 'find-bugs-plugin' which complains about a possible NPE here
if (cacheFile == null) {
continue;
}
if (!cacheFile.delete()) {
Ln.d("File '" + cacheFile.getName() + "' could not be deleted from cache.");
}
}
}

Expand Down

0 comments on commit db98ee8

Please sign in to comment.