[FIXED JENKINS-13202] Don't set mtime or mode on symlinks

Previously, the untar code tries to set the last modified time and mode
on every untarred file.  However, if the tar contains a broken symlink,
or a symlink that points to a file that has not been untarred yet, the
time/mode setting would fail on the broken symlink.

Symlinks don't have meaningful modified times or modes of their own, so
only set these values on non-symlinks.

Rename the file "a" in the test to expose the bug.
This commit is contained in:
David Reiss authored and Kohsuke Kawaguchi committed 2012-05-08 14:52:52 -07:00
1 parent 005effe68e
commit e15b2e19e3
3 files changed
+11 -9

No files matched your search

+3 -3
View File
@@ -365,8 +365,8 @@ public class FilePathTest extends ChannelTestCase {
try {
FilePath in = tmp.child("in");
in.mkdirs();
in.child("a").touch(0);
in.child("b").symlinkTo("a", TaskListener.NULL);
in.child("c").touch(0);
in.child("b").symlinkTo("c", TaskListener.NULL);
FilePath tar = tmp.child("test.tar");
in.tar(tar.write(), "**/*");
@@ -374,7 +374,7 @@ public class FilePathTest extends ChannelTestCase {
FilePath dst = in.child("dst");
tar.untar(dst, TarCompression.NONE);
assertEquals("a",dst.child("b").readLink());
assertEquals("c",dst.child("b").readLink());
} finally {
tmp.deleteRecursive();
}