From 54d409a7ddee3cf0db331a9a907a9f1c7fd60bff Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 28 Sep 2019 11:39:24 +0100 Subject: [PATCH] ftp: fix listing of an empty root returning: error dir not found Before this change if rclone listed an empty root directory then it would return an error dir not found. After this change we assume the root directory exists and don't attempt to check it which was failing before. See: https://forum.rclone.org/t/ftp-empty-directory-yields-directory-not-found-error/12069/ --- backend/ftp/ftp.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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")