From f5ee16e201af7e147a62dcb1f05f9bb218ad826f Mon Sep 17 00:00:00 2001 From: zjx20 Date: Wed, 6 Sep 2023 19:07:40 +0800 Subject: [PATCH] local: rmdir return an error if the path is not a dir --- backend/local/local.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/local/local.go b/backend/local/local.go index 5cee05af4..d1a613f5f 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -642,7 +642,13 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error { // // If it isn't empty it will return an error func (f *Fs) Rmdir(ctx context.Context, dir string) error { - return os.Remove(f.localPath(dir)) + localPath := f.localPath(dir) + if fi, err := os.Stat(localPath); err != nil { + return err + } else if !fi.IsDir() { + return fs.ErrorIsFile + } + return os.Remove(localPath) } // Precision of the file system