diff options
author | Andy Doan <andy.doan@linaro.org> | 2011-09-30 15:56:29 -0500 |
---|---|---|
committer | Andy Doan <doanac@gmail.com> | 2011-09-30 15:56:29 -0500 |
commit | 346a6b7459f1de908c57e944e6efb7f9fb5643a2 (patch) | |
tree | 821eb589176134ec0ac64c9ae71e55712ed564d3 | |
parent | d4d97c9b7ed328c4aa7cdaa0b2fdca43769c8a80 (diff) | |
download | LinaroConnect-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.java | 12 |
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); |