From b15fd92e267020c95637d518f557325b97dd2dec Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 18 Dec 2024 17:26:52 +0000 Subject: [PATCH] vfs: make overwriting directories give an error message - FIXME needs tests Fixes #8253 --- vfs/dir.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vfs/dir.go b/vfs/dir.go index a76d00cb1..50b8e42ea 100644 --- a/vfs/dir.go +++ b/vfs/dir.go @@ -1145,6 +1145,13 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error { fs.Errorf(oldPath, "Dir.Rename error: %v", err) return err } + // Check to see if we are overwriting something with a directory + _, err := d.vfs.Stat(newPath) + if err == nil { + return EEXIST + } else if err != ENOENT { + return err + } srcRemote := x.Remote() dstRemote := newPath err = operations.DirMove(context.TODO(), d.f, srcRemote, dstRemote)