ftpserver
ftpserver copied to clipboard
Some s3 service's capability of directory
In some s3 capable service such as minio , directory such as root / , not recognized as directory by api, so ftp client can't list directory. In this case, could we just treat path name with suffix / as directory? I had try it without thoughtful, it seams well.
diff --git a/handle_dirs.go b/handle_dirs.go
index e2c9cbb..08560f1 100644
--- a/handle_dirs.go
+++ b/handle_dirs.go
@@ -30,7 +30,7 @@ func (c *clientHandler) handleCWD(param string) error {
p := c.absPath(param)
if stat, err := c.driver.Stat(p); err == nil {
- if stat.IsDir() {
+ if stat.IsDir() || strings.HasSuffix(p, "/") { /*treat / suffix as directory*/
c.SetPath(p)
c.writeMessage(StatusFileOK, fmt.Sprintf("CD worked on %s", p))
} else {
@@ -325,7 +325,7 @@ func (c *clientHandler) getFileList(param string, filePathAllowed bool) ([]os.Fi
return nil, err
}
- if !info.IsDir() {
+ if !info.IsDir() && !strings.HasSuffix(listPath, "/") { /*treat / suffix as directory*/
if filePathAllowed {
return []os.FileInfo{info}, nil
}