From 43cf2ac30fcb4d562d8fbed3ea87743107e8bf92 Mon Sep 17 00:00:00 2001 From: Denis Lila Date: Fri, 4 Mar 2011 17:36:23 -0500 Subject: Fixed packed jar naming and pack.gz decompression problem. --- .../sourceforge/jnlp/cache/ResourceTracker.java | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'netx/net/sourceforge/jnlp/cache/ResourceTracker.java') 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); @@ -694,28 +711,11 @@ public class ResourceTracker { outputStream.write(buf, 0, rlen); } - 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 -- cgit v1.2.3