allow cross folder renaming if the underlying resource is the same

this was only allowed for the local filesystem before this change

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-08-15 21:39:04 +02:00
parent c86db09cd8
commit ced4206c5f
18 changed files with 558 additions and 70 deletions

View File

@@ -116,6 +116,9 @@ func (*OsFs) Create(name string, flag int) (File, *PipeWriter, func(), error) {
// Rename renames (moves) source to target
func (fs *OsFs) Rename(source, target string) error {
if source == target {
return nil
}
err := os.Rename(source, target)
if err != nil && isCrossDeviceError(err) {
fsLog(fs, logger.LevelError, "cross device error detected while renaming %#v -> %#v. Trying a copy and remove, this could take a long time",