From dc086f6425aad4d70ea1c19166c5fc153450db1e Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 11 Apr 2009 21:17:15 +0000 Subject: [PATCH] supported the zip file as well git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@17064 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/FilePath.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index c4dfd454df..3d2bd461ac 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -465,7 +465,7 @@ public final class FilePath implements Serializable { } /** - * Given a tgz file, extracts it to the given target directory, if necessary. + * Given a tgz/zip file, extracts it to the given target directory, if necessary. * *

* This method is a convenience method designed for installing a binary package to a location @@ -474,12 +474,12 @@ public final class FilePath implements Serializable { *

* - * @param tgz - * The resource that represents the tgz file. This URL must support the "Last-Modified" header. + * @param archive + * The resource that represents the tgz/zip file. This URL must support the "Last-Modified" header. * (Most common usage is to get this from {@link ClassLoader#getResource(String)}) * @param listener * If non-null, a message will be printed to this listener once this method decides to @@ -489,8 +489,8 @@ public final class FilePath implements Serializable { * was considered up to date. * @since 1.299 */ - public boolean installIfNecessaryFrom(URL tgz, TaskListener listener, String message) throws IOException, InterruptedException { - URLConnection con = tgz.openConnection(); + public boolean installIfNecessaryFrom(URL archive, TaskListener listener, String message) throws IOException, InterruptedException { + URLConnection con = archive.openConnection(); long sourceTimestamp = con.getLastModified(); FilePath timestamp = this.child(".timestamp"); @@ -502,7 +502,10 @@ public final class FilePath implements Serializable { if(listener!=null) listener.getLogger().println(message); - untarFrom(con.getInputStream(),GZIP); + if(archive.toExternalForm().endsWith(".zip")) + unzipFrom(con.getInputStream()); + else + untarFrom(con.getInputStream(),GZIP); timestamp.touch(sourceTimestamp); return true; }