-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sftp readdir: determine file type from longname
Some SFTP v3 servers do not include the file type flags in the permissions field of an SSH_FXP_NAME record. It this case use the "longname" field to extract this information, if possible. Also give the SftpClientDirectoryScanner and the DirectoryScanner a flag to make them return not only regular files but also links and other items. (DirectoryScanner already returned links to regular files; SftpClientDirectoryScanner did not.) Bug: #489
- Loading branch information
Showing
5 changed files
with
311 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,11 @@ | |
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> | ||
*/ | ||
public class SftpClientDirectoryScanner extends PathScanningMatcher { | ||
|
||
protected String basedir; | ||
|
||
private boolean filesOnly = true; | ||
|
||
public SftpClientDirectoryScanner() { | ||
this(true); | ||
} | ||
|
@@ -68,6 +71,25 @@ public SftpClientDirectoryScanner(String dir, Collection<String> includes) { | |
setIncludes(includes); | ||
} | ||
|
||
/** | ||
* Tells whether the scanner is set to return only files and links (the default). | ||
* | ||
* @return {@code true} if items that are not regular files or subdirectories shall be omitted; {@code false} | ||
* otherwise | ||
*/ | ||
public boolean isFilesOnly() { | ||
return filesOnly; | ||
} | ||
|
||
/** | ||
* Sets whether the scanner shall return only regular files, links, and subdirectories. | ||
* | ||
* @param filesOnly whether to skip all items that are not regular files, links, or subdirectories | ||
*/ | ||
public void setFilesOnly(boolean filesOnly) { | ||
this.filesOnly = filesOnly; | ||
} | ||
|
||
public String getBasedir() { | ||
return basedir; | ||
} | ||
|
@@ -171,7 +193,7 @@ protected <C extends Collection<ScanDirEntry>> C scandir( | |
} else if (couldHoldIncluded(name)) { | ||
scandir(client, createRelativePath(rootDir, name), createRelativePath(parent, name), filesList); | ||
} | ||
} else if (attrs.isRegularFile()) { | ||
} else if (!filesOnly || attrs.isRegularFile() || attrs.isSymbolicLink()) { | ||
if (isIncluded(name)) { | ||
filesList.add(new ScanDirEntry(createRelativePath(rootDir, name), createRelativePath(parent, name), de)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.