diff --git a/changelog.html b/changelog.html index 339ce25cf8..f1b1cbefb2 100644 --- a/changelog.html +++ b/changelog.html @@ -55,6 +55,8 @@ Upcoming changes
+ * If the resolution fails, report an error.
+ *
+ * @since 1.456
+ */
+ public String readLink() throws IOException, InterruptedException {
+ return act(new FileCallable
@@ -1030,7 +1038,7 @@ public class Util {
* @param listener
* If we rely on an external command to resolve symlink, this is it.
*/
- public static String resolveSymlink(File link, TaskListener listener) throws InterruptedException, IOException {
+ public static String resolveSymlink(File link) throws InterruptedException, IOException {
if(Functions.isWindows()) return null;
String filename = link.getAbsolutePath();
diff --git a/core/src/main/java/hudson/util/DirScanner.java b/core/src/main/java/hudson/util/DirScanner.java
index 4e33501c9c..78ba917f9e 100644
--- a/core/src/main/java/hudson/util/DirScanner.java
+++ b/core/src/main/java/hudson/util/DirScanner.java
@@ -101,6 +101,18 @@ public abstract class DirScanner implements Serializable {
DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project());
for( String f : ds.getIncludedFiles()) {
File file = new File(dir, f);
+
+ if (visitor.understandsSymlink()) {
+ try {
+ String target = Util.resolveSymlink(file,TaskListener.NULL);
+ if (target!=null) {
+ visitor.visitSymlink(file,target,f);
+ continue;
+ }
+ } catch (InterruptedException e) {
+ throw (IOException)new InterruptedIOException().initCause(e);
+ }
+ }
visitor.visit(file,f);
}
}
diff --git a/core/src/test/java/hudson/FilePathTest.java b/core/src/test/java/hudson/FilePathTest.java
index 477a08299e..4122205375 100644
--- a/core/src/test/java/hudson/FilePathTest.java
+++ b/core/src/test/java/hudson/FilePathTest.java
@@ -23,6 +23,8 @@
*/
package hudson;
+import hudson.FilePath.TarCompression;
+import hudson.model.TaskListener;
import hudson.remoting.LocalChannel;
import hudson.remoting.VirtualChannel;
import hudson.util.IOException2;
@@ -356,4 +358,25 @@ public class FilePathTest extends ChannelTestCase {
}
}
+ public void testSymlinkInTar() throws Exception {
+ if (Functions.isWindows()) return; // can't test on Windows
+
+ FilePath tmp = new FilePath(Util.createTempDir());
+ try {
+ FilePath in = tmp.child("in");
+ in.mkdirs();
+ in.child("a").touch(0);
+ in.child("b").symlinkTo("a", TaskListener.NULL);
+
+ FilePath tar = tmp.child("test.tar");
+ in.tar(tar.write(), "**/*");
+
+ FilePath dst = in.child("dst");
+ tar.untar(dst, TarCompression.NONE);
+
+ assertEquals("a",dst.child("b").readLink());
+ } finally {
+ tmp.deleteRecursive();
+ }
+ }
}
diff --git a/pom.xml b/pom.xml
index 8cb9d59a5e..add4271c4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -136,7 +136,7 @@ THE SOFTWARE.