changeset 233:aea73e8365fe

Fix PR727: Split conditional to removed duplicate entries in cache.
author Andrew Su <asu@redhat.com>
date Fri, 27 May 2011 12:32:52 -0400
parents d74fed364c47
children a962e87c78e8
files ChangeLog NEWS netx/net/sourceforge/jnlp/cache/CacheUtil.java
diffstat 3 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed May 25 15:13:19 2011 -0400
+++ b/ChangeLog	Fri May 27 12:32:52 2011 -0400
@@ -1,3 +1,9 @@
+2011-05-26  Andrew Su  <asu@redhat.com>
+
+	* NEWS: Update.
+	* netx/net/sourceforge/jnlp/cache/CacheUtil.java:
+	(cleanCache): Split conditional for delete.
+
 2011-05-20  Andrew Su  <asu@redhat.com>
 
 	* NEWS: Update.
--- a/NEWS	Wed May 25 15:13:19 2011 -0400
+++ b/NEWS	Fri May 27 12:32:52 2011 -0400
@@ -27,6 +27,7 @@
   - RH669942: javaws fails to download version/packed files (missing support for jnlp.packEnabled and jnlp.versionEnabled)
   - PR658: now jnlp.packEnabled works with applets.
   - PR726: closing javaws -about no longer throws exceptions.
+  - PR727: cache now properly removes files.
 * Plugin
   - PR475, RH604061: Allow applets from the same page to use the same classloader
   - PR612: NetDania application ends on java.security.AccessControlException: access denied (java.util.PropertyPermission browser read)
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java	Wed May 25 15:13:19 2011 -0400
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java	Fri May 27 12:32:52 2011 -0400
@@ -567,6 +567,11 @@
                     rStr = cacheDir + rStr.substring(0, rStr.indexOf(File.separatorChar, 1));
                     long len = file.length();
 
+                    if (keep.contains(file.getPath().substring(rStr.length()))) {
+                        lruHandler.removeEntry(key);
+                        continue;
+                    }
+                    
                     /*
                      * we remove entries from our lru if any of the following condition is met.
                      * Conditions:
@@ -574,11 +579,8 @@
                      *  - !file.isFile(): if someone tampered with the directory, file doesn't exist.
                      *  - maxSize >= 0 && curSize + len > maxSize: If a limit was set and the new size
                      *  on disk would exceed the maximum size.
-                     *  - keep.contains(...): We had already decided to keep an entry with the same
-                     *  url path.
                      */
-                    if (delete || !file.isFile() || (maxSize >= 0 && curSize + len > maxSize) ||
-                            keep.contains(file.getPath().substring(rStr.length()))) {
+                    if (delete || !file.isFile() || (maxSize >= 0 && curSize + len > maxSize)) {
                         lruHandler.removeEntry(key);
                         remove.add(rStr);
                     } else {