From 3fabae87fec6e9bd4969f9910a20456fb742391b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 18 Dec 2024 17:25:15 +0000 Subject: [PATCH] Revert "operations: fix error reporting which was causing mount to overwrite directories." This reverts commit 2d0007d1a5986af642c7c619a42646600663f6b0. --- fs/operations/operations.go | 2 +- fs/operations/operations_test.go | 41 -------------------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index 58b61e38b..eeba711fb 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -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 { + if err != fs.ErrorCantDirMove && err != fs.ErrorDirExists { return err } fs.Infof(f, "Can't DirMove - falling back to file moves: %v", err) diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.go index 26aa0f11e..3f02c1bf1 100644 --- a/fs/operations/operations_test.go +++ b/fs/operations/operations_test.go @@ -1452,47 +1452,6 @@ 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)