aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
diff options
context:
space:
mode:
authorDenis Lila <dlila@redhat.com>2011-03-04 17:36:23 -0500
committerDenis Lila <dlila@redhat.com>2011-03-04 17:36:23 -0500
commit43cf2ac30fcb4d562d8fbed3ea87743107e8bf92 (patch)
tree93e9dd5dcf951deb638af35840e56949bc152a46 /netx/net/sourceforge/jnlp/cache/ResourceTracker.java
parenteb116d00b1dfee2df7b1dc6191d388a4b0f4b846 (diff)
Fixed packed jar naming and pack.gz decompression problem.
Diffstat (limited to 'netx/net/sourceforge/jnlp/cache/ResourceTracker.java')
-rw-r--r--netx/net/sourceforge/jnlp/cache/ResourceTracker.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
index 93e763e..9e033cf 100644
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
@@ -653,11 +653,14 @@ public class ResourceTracker {
}
- if ("gzip".equals(contentEncoding)) {
- downloadLocation = new URL(downloadLocation.toString() + ".gz");
- } else if ("pack200-gzip".equals(contentEncoding) ||
- realLocation.getPath().endsWith(".pack.gz")) {
+ boolean packgz = "pack200-gzip".equals(contentEncoding) ||
+ realLocation.getPath().endsWith(".pack.gz");
+ boolean gzip = "gzip".equals(contentEncoding);
+
+ if (packgz) {
downloadLocation = new URL(downloadLocation.toString() + ".pack.gz");
+ } else if (gzip) {
+ downloadLocation = new URL(downloadLocation.toString() + ".gz");
}
InputStream in = new BufferedInputStream(con.getInputStream());
@@ -681,7 +684,21 @@ public class ResourceTracker {
* If the file was compressed, uncompress it.
*/
- if ("gzip".equals(contentEncoding)) {
+ if (packgz) {
+ GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(
+ CacheUtil.getCacheFile(downloadLocation, resource.downloadVersion)));
+ InputStream inputStream = new BufferedInputStream(gzInputStream);
+
+ JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(
+ CacheUtil.getCacheFile(resource.location, resource.downloadVersion)));
+
+ Unpacker unpacker = Pack200.newUnpacker();
+ unpacker.unpack(inputStream, outputStream);
+
+ outputStream.close();
+ inputStream.close();
+ gzInputStream.close();
+ } else if (gzip) {
GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(CacheUtil
.getCacheFile(downloadLocation, resource.downloadVersion)));
InputStream inputStream = new BufferedInputStream(gzInputStream);
@@ -697,25 +714,8 @@ public class ResourceTracker {
outputStream.close();
inputStream.close();
gzInputStream.close();
-
- } else if ("pack200-gzip".equals(contentEncoding) ||
- realLocation.getPath().endsWith(".pack.gz")) {
- GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(
- CacheUtil.getCacheFile(downloadLocation, resource.downloadVersion)));
- InputStream inputStream = new BufferedInputStream(gzInputStream);
-
- JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(
- CacheUtil.getCacheFile(resource.location, resource.downloadVersion)));
-
- Unpacker unpacker = Pack200.newUnpacker();
- unpacker.unpack(inputStream, outputStream);
-
- outputStream.close();
- inputStream.close();
- gzInputStream.close();
}
-
resource.changeStatus(DOWNLOADING, DOWNLOADED);
synchronized (lock) {
lock.notifyAll(); // wake up wait's to check for completion