Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some s3 service's capability of directory #801

Open
cndonnie opened this issue Sep 16, 2022 · 0 comments
Open

Some s3 service's capability of directory #801

cndonnie opened this issue Sep 16, 2022 · 0 comments

Comments

@cndonnie
Copy link

cndonnie commented Sep 16, 2022

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
 		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant