mirror of
https://github.com/rclone/rclone.git
synced 2025-03-06 03:11:44 +01:00
operations: fix error reporting which was causing mount to overwrite directories.
Before this change, in rclone mount, rclone was not erroring if one
directory was moved over another, instead the contents were combined.
This was caused by this commit
431524445e
combine: fix operations.DirMove across upstreams - fixes #7661
The fix is to sharpen the conditions that the fallback code runs.
Fixes #8253
This commit is contained in:
parent
0ce2e12d9f
commit
2d0007d1a5
@ -2404,7 +2404,7 @@ func DirMove(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err err
|
||||
if err == nil {
|
||||
accounting.Stats(ctx).Renames(1)
|
||||
}
|
||||
if err != fs.ErrorCantDirMove && err != fs.ErrorDirExists {
|
||||
if err != fs.ErrorCantDirMove {
|
||||
return err
|
||||
}
|
||||
fs.Infof(f, "Can't DirMove - falling back to file moves: %v", err)
|
||||
|
@ -1452,6 +1452,47 @@ func TestDirMove(t *testing.T) {
|
||||
)
|
||||
}
|
||||
|
||||
func TestDirMoveOverwrite(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r := fstest.NewRun(t)
|
||||
|
||||
if !r.Fremote.Features().CanHaveEmptyDirectories {
|
||||
t.Skip("Can't test for directory overwrite if can't have empty directories")
|
||||
}
|
||||
|
||||
r.Mkdir(ctx, r.Fremote)
|
||||
|
||||
// Make some files and dirs
|
||||
r.ForceMkdir(ctx, r.Fremote)
|
||||
require.NoError(t, operations.Mkdir(ctx, r.Fremote, "dir1"))
|
||||
require.NoError(t, operations.Mkdir(ctx, r.Fremote, "dir2"))
|
||||
|
||||
fstest.CheckListingWithPrecision(
|
||||
t,
|
||||
r.Fremote,
|
||||
nil,
|
||||
[]string{
|
||||
"dir1",
|
||||
"dir2",
|
||||
},
|
||||
fs.GetModifyWindow(ctx, r.Fremote),
|
||||
)
|
||||
|
||||
// Check we get an error if we try to overwrite an existing directory
|
||||
require.Error(t, operations.DirMove(ctx, r.Fremote, "dir1", "dir2"))
|
||||
|
||||
fstest.CheckListingWithPrecision(
|
||||
t,
|
||||
r.Fremote,
|
||||
nil,
|
||||
[]string{
|
||||
"dir1",
|
||||
"dir2",
|
||||
},
|
||||
fs.GetModifyWindow(ctx, r.Fremote),
|
||||
)
|
||||
}
|
||||
|
||||
func TestGetFsInfo(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user