Skip to content

Commit

Permalink
Fixing issue #1156
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Jul 12, 2007
1 parent d7a7cf8 commit be764c0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
24 changes: 13 additions & 11 deletions source/ch/cyberduck/core/Path.java
Expand Up @@ -303,17 +303,19 @@ public String getAbsolute() {
public void setLocal(Local file) {
if(null != file) {
if(file.attributes.isSymbolicLink()) {
/**
* A canonical pathname is both absolute and unique. The precise
* definition of canonical form is system-dependent. This method first
* converts this pathname to absolute form if necessary, as if by invoking the
* {@link #getAbsolutePath} method, and then maps it to its unique form in a
* system-dependent way. This typically involves removing redundant names
* such as <tt>"."</tt> and <tt>".."</tt> from the pathname, resolving
* symbolic links
*/
this.local = new Local(file.getSymbolicLinkPath());
return;
if(null != file.getSymbolicLinkPath()) {
/**
* A canonical pathname is both absolute and unique. The precise
* definition of canonical form is system-dependent. This method first
* converts this pathname to absolute form if necessary, as if by invoking the
* {@link #getAbsolutePath} method, and then maps it to its unique form in a
* system-dependent way. This typically involves removing redundant names
* such as <tt>"."</tt> and <tt>".."</tt> from the pathname, resolving
* symbolic links
*/
this.local = new Local(file.getSymbolicLinkPath());
return;
}
}
}
this.local = file;
Expand Down
24 changes: 15 additions & 9 deletions source/ch/cyberduck/core/sftp/SFTPPath.java
Expand Up @@ -127,16 +127,22 @@ public boolean add(Object object) {
p.attributes.setModificationDate(Long.parseLong(f.attributes.mtime.toString()) * 1000L);
p.attributes.setAccessedDate(Long.parseLong(f.attributes.atime.toString()) * 1000L);
if(f.attributes.isSymlink()) {
String target = session.sftp().readLink(p.getAbsolute());
if(!target.startsWith("/")) {
target = Path.normalize(this.getAbsolute() + Path.DELIMITER + target);
}
p.setSymbolicLinkPath(target);
SFTPv3FileAttributes attr = session.sftp().stat(target);
if(attr.isDirectory()) {
p.attributes.setType(Path.SYMBOLIC_LINK_TYPE | Path.DIRECTORY_TYPE);
try {
String target = session.sftp().readLink(p.getAbsolute());
if(!target.startsWith("/")) {
target = Path.normalize(this.getAbsolute() + Path.DELIMITER + target);
}
p.setSymbolicLinkPath(target);
SFTPv3FileAttributes attr = session.sftp().stat(target);
if(attr.isDirectory()) {
p.attributes.setType(Path.SYMBOLIC_LINK_TYPE | Path.DIRECTORY_TYPE);
}
else if(attr.isRegularFile()) {
p.attributes.setType(Path.SYMBOLIC_LINK_TYPE | Path.FILE_TYPE);
}
}
else if(attr.isRegularFile()) {
catch(IOException e) {
log.warn("Cannot read symbolic link target of "+p.getAbsolute()+":"+e.getMessage());
p.attributes.setType(Path.SYMBOLIC_LINK_TYPE | Path.FILE_TYPE);
}
}
Expand Down

0 comments on commit be764c0

Please sign in to comment.