From a9e7e7bcc26272b6ad17cc9fff3e652869203ccf Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 28 Mar 2023 07:26:28 +0100 Subject: [PATCH] ftp: Fix "501 Not a valid pathname." errors when creating directories Some servers return a 501 error when using MLST on a non-existing directory. This patch allows it. I don't think this is correct usage according to the RFC, but the RFC doesn't explicitly state which error code should be returned for file/directory not found. --- backend/ftp/ftp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index 0419971fa..cedd07861 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -693,6 +693,12 @@ func (f *Fs) findItem(ctx context.Context, remote string) (entry *ftp.Entry, err if err == fs.ErrorObjectNotFound { return nil, nil } + if errX := textprotoError(err); errX != nil { + switch errX.Code { + case ftp.StatusBadArguments: + err = nil + } + } return nil, err } if entry != nil {