changeset 240:60b21220df55

Fix cache to allow redownload on next run when javaws is killed
author Andrew Su <asu@redhat.com>
date Mon, 30 May 2011 13:50:35 -0400
parents de182e65a6e1
children 6ca669aa114a
files ChangeLog netx/net/sourceforge/jnlp/cache/ResourceTracker.java
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon May 30 13:15:50 2011 -0400
+++ b/ChangeLog	Mon May 30 13:50:35 2011 -0400
@@ -1,3 +1,8 @@
+2011-05-30  Andrew Su  <asu@redhat.com>
+
+	* netx/net/sourceforge/jnlp/cache/ResourceTracker.java:
+	(downloadResource): Check whether file to be downloaded is current.
+
 2011-05-30  Andrew Su  <asu@redhat.com>
 
 	* netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java:
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java	Mon May 30 13:15:50 2011 -0400
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java	Mon May 30 13:50:35 2011 -0400
@@ -675,7 +675,7 @@
             CacheEntry downloadEntry = new CacheEntry(downloadLocation, resource.downloadVersion);
             File finalFile = CacheUtil.getCacheFile(resource.location, resource.downloadVersion); // This is where extracted version will be, or downloaded file if not compressed.
 
-            if (!finalFile.exists()) {
+            if (!downloadEntry.isCurrent(con)) {
                 // Make sure we don't re-download the file. however it will wait as if it was downloading.
                 // (This is fine because file is not ready yet anyways)
                 byte buf[] = new byte[1024];
@@ -700,6 +700,7 @@
                  * If the file was compressed, uncompress it.
                  */
                 if (packgz) {
+                    downloadEntry.initialize(con);
                     GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(CacheUtil
                             .getCacheFile(downloadLocation, resource.downloadVersion)));
                     InputStream inputStream = new BufferedInputStream(gzInputStream);
@@ -714,6 +715,7 @@
                     inputStream.close();
                     gzInputStream.close();
                 } else if (gzip) {
+                    downloadEntry.initialize(con);
                     GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(CacheUtil
                             .getCacheFile(downloadLocation, resource.downloadVersion)));
                     InputStream inputStream = new BufferedInputStream(gzInputStream);