[jira] [Commented] (VFS-179) Traversal of directory tree with FileSelector fails with symbolic links in SFTP
[ https://issues.apache.org/jira/browse/VFS-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145320#comment-13145320 ] Kirill Safonov commented on VFS-179: There's a bug the the patch: one should call fileSystem.putChannel() in finally{} block otherwise SFTP connection will be open forever. This inevitably leads to 'Channel is not opened' errors once connection limit on server is reached. > Traversal of directory tree with FileSelector fails with symbolic links in > SFTP > --- > > Key: VFS-179 > URL: https://issues.apache.org/jira/browse/VFS-179 > Project: Commons VFS > Issue Type: Bug >Reporter: Andrew Franklin > Attachments: VFS-179.patch > > > It seems to me that when using the FileSelector to traverse a directory tree > using SFTP, a symbolic link will return as type File (even when the link > points to a directory), which will result in the directory node not being > followed. > By using a mechanism similar to that of FtpFileObject this can be resolved > with the following... > {noformat} > protected FileType doGetType() throws Exception > { > if (attrs == null) > { > statSelf(); > } > if (attrs == null) > { > return FileType.IMAGINARY; > } > if ((attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0) > { > throw new FileSystemException( > "vfs.provider.sftp/unknown-permissions.error"); > } > if(attrs.isLink()) > { > return getLinkDestination().getType(); > } > else if (attrs.isDir()) > { > return FileType.FOLDER; > } > else > { > return FileType.FILE; > } > } > /** > * Return the destination of this file object if it's a symbolic link > * @return FileObject representing the linked to location > */ > private FileObject getLinkDestination() throws Exception > { > if (linkDestination == null) > { > final String path = fileSystem.getChannel().readlink( relPath ); > FileName relativeTo = getName().getParent(); > if (relativeTo == null) > { > relativeTo = getName(); > } > FileName linkDestinationName = > getFileSystem().getFileSystemManager().resolveName(relativeTo, path); > linkDestination = > getFileSystem().resolveFile(linkDestinationName); > } > return linkDestination; > } > {noformat} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (VFS-179) Traversal of directory tree with FileSelector fails with symbolic links in SFTP
[ https://issues.apache.org/jira/browse/VFS-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13056890#comment-13056890 ] Andrew Franklin commented on VFS-179: - Hi Henning, I've been running with the patch since 2007 with no problems. > Traversal of directory tree with FileSelector fails with symbolic links in > SFTP > --- > > Key: VFS-179 > URL: https://issues.apache.org/jira/browse/VFS-179 > Project: Commons VFS > Issue Type: Bug >Reporter: Andrew Franklin > Attachments: VFS-179.patch > > > It seems to me that when using the FileSelector to traverse a directory tree > using SFTP, a symbolic link will return as type File (even when the link > points to a directory), which will result in the directory node not being > followed. > By using a mechanism similar to that of FtpFileObject this can be resolved > with the following... > {noformat} > protected FileType doGetType() throws Exception > { > if (attrs == null) > { > statSelf(); > } > if (attrs == null) > { > return FileType.IMAGINARY; > } > if ((attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0) > { > throw new FileSystemException( > "vfs.provider.sftp/unknown-permissions.error"); > } > if(attrs.isLink()) > { > return getLinkDestination().getType(); > } > else if (attrs.isDir()) > { > return FileType.FOLDER; > } > else > { > return FileType.FILE; > } > } > /** > * Return the destination of this file object if it's a symbolic link > * @return FileObject representing the linked to location > */ > private FileObject getLinkDestination() throws Exception > { > if (linkDestination == null) > { > final String path = fileSystem.getChannel().readlink( relPath ); > FileName relativeTo = getName().getParent(); > if (relativeTo == null) > { > relativeTo = getName(); > } > FileName linkDestinationName = > getFileSystem().getFileSystemManager().resolveName(relativeTo, path); > linkDestination = > getFileSystem().resolveFile(linkDestinationName); > } > return linkDestination; > } > {noformat} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (VFS-179) Traversal of directory tree with FileSelector fails with symbolic links in SFTP
[ https://issues.apache.org/jira/browse/VFS-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012883#comment-13012883 ] Henning Kvinnesland commented on VFS-179: - Does the patch work? > Traversal of directory tree with FileSelector fails with symbolic links in > SFTP > --- > > Key: VFS-179 > URL: https://issues.apache.org/jira/browse/VFS-179 > Project: Commons VFS > Issue Type: Bug >Reporter: Andrew Franklin > Attachments: VFS-179.patch > > > It seems to me that when using the FileSelector to traverse a directory tree > using SFTP, a symbolic link will return as type File (even when the link > points to a directory), which will result in the directory node not being > followed. > By using a mechanism similar to that of FtpFileObject this can be resolved > with the following... > /** >* Determines the type of this file, returns null if the file does not >* exist. >*/ > protected FileType doGetType() throws Exception > { > if (attrs == null) > { > statSelf(); > } > if (attrs == null) > { > return FileType.IMAGINARY; > } > if ((attrs.getFlags() & > SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0) > { > throw new FileSystemException( > > "vfs.provider.sftp/unknown-permissions.error"); > } > if(attrs.isLink()) > { > return getLinkDestination().getType(); > } > else if (attrs.isDir()) > { > return FileType.FOLDER; > } > else > { > return FileType.FILE; > } > } > /** >* Return the destination of this file object if it's a symbolic link >* @return FileObject representing the linked to location >*/ > private FileObject getLinkDestination() throws Exception > { > if (linkDestination == null) > { > final String path = fileSystem.getChannel().readlink( > relPath ); > FileName relativeTo = getName().getParent(); > if (relativeTo == null) > { > relativeTo = getName(); > } > FileName linkDestinationName = > getFileSystem().getFileSystemManager().resolveName(relativeTo, path); > linkDestination = > getFileSystem().resolveFile(linkDestinationName); > } > return linkDestination; > } -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira