aleksas edited a comment on Bug JENKINS-15587

The issue is with the File.getCanonicalFile() function. It doesn't resolve the original directory name from NTFS symlink.

UPDATED:
"java.hudson.Util.resolveSymlink(File)" should be used instead of "File.getCanonicalFile()".

To see the code look here: function parseTimestampFromBuildDir in https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Run.java .

To test the problem one can compile (jdk1.7) and run code below (change "./294" to appropriate symlink path)
To create directory symlink on windows Vista/7/2008 run command: mklink /D symlinkname targetdirpath (e.g. mklink /D win "C:\Windows")

MainClass.java code:

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Files;
import java.io.IOException;

public class MainClass {
public static void main(String [] args) {
File file = new File("./294");
try { if(file.isDirectory()) System.out.print("Dir "); else System.out.print("File "); if(Files.isSymbolicLink(file.toPath())) System.out.print("Symlink "); System.out.println(file.getAbsolutePath()); System.out.println(file.getCanonicalFile().getName()); System.out.println(file.getCanonicalFile().getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); }
}
}

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to