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

local: rmdir return an error if the path is not a dir

zjx20f5ee16e201af
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