[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

+5 -5
View File
@@ -1812,12 +1812,12 @@ public final class FilePath implements Serializable {
new FilePath(f).symlinkTo(te.getLinkName(), TaskListener.NULL);
} else {
IOUtils.copy(t,f);
f.setLastModified(te.getModTime().getTime());
int mode = te.getMode()&0777;
if(mode!=0 && !Functions.isWindows()) // be defensive
_chmod(f,mode);
}
f.setLastModified(te.getModTime().getTime());
int mode = te.getMode()&0777;
if(mode!=0 && !Functions.isWindows()) // be defensive
_chmod(f,mode);
}
}
} catch(IOException e) {