mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 04:41:17 +08:00
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/
This commit is contained in:
parent
6750af6167
commit
fef8b98be2
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user