aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2011-09-30 15:56:29 -0500
committerAndy Doan <doanac@gmail.com>2011-09-30 15:56:29 -0500
commit346a6b7459f1de908c57e944e6efb7f9fb5643a2 (patch)
tree821eb589176134ec0ac64c9ae71e55712ed564d3
parentd4d97c9b7ed328c4aa7cdaa0b2fdca43769c8a80 (diff)
downloadLinaroConnect-346a6b7459f1de908c57e944e6efb7f9fb5643a2.tar.gz
remove bad items from cache
if for some reason a file disappears from the cache (say you delete it from adb), we need to purge the entry from the cache
-rw-r--r--src/org/linaro/connect/LRUCache.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/org/linaro/connect/LRUCache.java b/src/org/linaro/connect/LRUCache.java
index 0623a7c..244ac6b 100644
--- a/src/org/linaro/connect/LRUCache.java
+++ b/src/org/linaro/connect/LRUCache.java
@@ -38,8 +38,16 @@ class LRUCache extends LinkedHashMap<String, File> {
public InputStream getInputStream(String url) throws IOException {
File f = get(url);
- if( f != null )
- return new FileInputStream(f);
+ if( f != null ) {
+ try {
+ return new FileInputStream(f);
+ }
+ catch(IOException e) {
+ remove(url);
+ f.delete();
+ throw e;
+ }
+ }
File cacheFile = toCacheFile(url);
return new CachingInputStream(url, cacheFile);