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

This commit is contained in:
zjx20 2023-09-06 19:07:40 +08:00 committed by Nick Craig-Wood
parent 2bcbed30bd
commit f5ee16e201
1 changed files with 7 additions and 1 deletions

View File

@ -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