提交 2dd70965 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-9118]

WorkspaceSnapshot now uses the tar.gz format to handle symlinks
correctly.
上级 d184d53b
......@@ -56,7 +56,8 @@ Upcoming changes</a>
<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 final class FilePath implements Serializable {
});
}
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,6 +23,7 @@
*/
package hudson;
import hudson.FilePath.TarCompression;
import hudson.matrix.MatrixBuild;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
......@@ -30,6 +31,8 @@ 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 abstract class FileSystemProvisioner implements ExtensionPoint, Describab
* 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 abstract class FileSystemProvisioner implements ExtensionPoint, Describab
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);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册