Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

ftp: fix listing of an empty root returning: error dir not found

Nick Craig-Woodfef8b98be234
diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go
index 95756a85a..88eb59ab1 100644
--- a/backend/ftp/ftp.go
+++ b/backend/ftp/ftp.go
@@ -299,6 +299,14 @@ func translateErrorDir(err error) error {
func (f *Fs) findItem(remote string) (entry *ftp.Entry, err error) {
// defer fs.Trace(remote, "")("o=%v, err=%v", &o, &err)
fullPath := path.Join(f.root, remote)
+ if fullPath == "" || fullPath == "." || fullPath == "/" {
+ // if root, assume exists and synthesize an entry
+ return &ftp.Entry{
+ Name: "",
+ Type: ftp.EntryTypeFolder,
+ Time: time.Now(),
+ }, nil
+ }
dir := path.Dir(fullPath)
base := path.Base(fullPath)
@@ -366,7 +374,7 @@ func (f *Fs) dirExists(remote string) (exists bool, err error) {
// This should return ErrDirNotFound if the directory isn't
// found.
func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error) {
- // defer fs.Trace(dir, "curlevel=%d", curlevel)("")
+ // defer log.Trace(dir, "dir=%q", dir)("entries=%v, err=%v", &entries, &err)
c, err := f.getFtpConnection()
if err != nil {
return nil, errors.Wrap(err, "list")