Skip to content
Permalink
Browse files

[FIXED JENKINS-9118]

WorkspaceSnapshot now uses the tar.gz format to handle symlinks
correctly.
  • Loading branch information
kohsuke committed Mar 10, 2012
1 parent d184d53 commit 2dd70965a781f3f8477ce06d1ecf61f6c3017ace
Showing with 16 additions and 7 deletions.
  1. +2 −1 changelog.html
  2. +2 −2 core/src/main/java/hudson/FilePath.java
  3. +12 −4 core/src/main/java/hudson/FileSystemProvisioner.java
@@ -56,7 +56,8 @@
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
tar/untar now correctly handles symlinks.
Workspace archiving wasn't handling symlinks correctly.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9118">issue 9118</a>)
<li class=bug>
Fixed a bug in the auto-overwrite of bundled plugins on Windows.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12514">issue 12514</a>)
@@ -415,11 +415,11 @@ public Integer invoke(File f, VirtualChannel channel) throws IOException {
});
}

private int archive(final ArchiverFactory factory, OutputStream os, final FileFilter filter) throws IOException, InterruptedException {
public int archive(final ArchiverFactory factory, OutputStream os, final FileFilter filter) throws IOException, InterruptedException {
return archive(factory,os,new DirScanner.Filter(filter));
}

private int archive(final ArchiverFactory factory, OutputStream os, final String glob) throws IOException, InterruptedException {
public int archive(final ArchiverFactory factory, OutputStream os, final String glob) throws IOException, InterruptedException {
return archive(factory,os,new DirScanner.Glob(glob,null));
}

@@ -23,13 +23,16 @@
*/
package hudson;

import hudson.FilePath.TarCompression;
import hudson.matrix.MatrixBuild;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Computer;
import hudson.model.Describable;
import hudson.model.Job;
import hudson.model.TaskListener;
import hudson.util.DirScanner.Glob;
import hudson.util.io.ArchiverFactory;
import jenkins.model.Jenkins;
import hudson.model.listeners.RunListener;
import hudson.scm.SCM;
@@ -211,10 +214,10 @@ public WorkspaceSnapshot snapshot(AbstractBuild<?, ?> build, FilePath ws, TaskLi
* Creates a tar ball.
*/
public WorkspaceSnapshot snapshot(AbstractBuild<?, ?> build, FilePath ws, String glob, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(build.getRootDir(),"workspace.zip");
File wss = new File(build.getRootDir(),"workspace.tgz");
OutputStream os = new BufferedOutputStream(new FileOutputStream(wss));
try {
ws.zip(os,glob);
ws.archive(ArchiverFactory.TARGZ,os,glob);
} finally {
os.close();
}
@@ -223,8 +226,13 @@ public WorkspaceSnapshot snapshot(AbstractBuild<?, ?> build, FilePath ws, String

public static final class WorkspaceSnapshotImpl extends WorkspaceSnapshot {
public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(owner.getRootDir(),"workspace.zip");
new FilePath(wss).unzip(dst);
File zip = new File(owner.getRootDir(),"workspace.zip");
if (zip.exists()) {// we used to keep it in zip
new FilePath(zip).unzip(dst);
} else {// but since 1.456 we do tgz
File tgz = new File(owner.getRootDir(),"workspace.tgz");
new FilePath(tgz).untar(dst, TarCompression.GZIP);
}
}
}

0 comments on commit 2dd7096

Please sign in to comment.
You can’t perform that action at this time.