mirror of
https://github.com/rclone/rclone.git
synced 2025-08-16 08:38:11 +02:00
operations: fix TransformFile when can't server-side copy/move
This commit is contained in:
@ -493,6 +493,9 @@ func move(ctx context.Context, fdst fs.Fs, dst fs.Object, remote string, src fs.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Move not found or didn't work so copy dst <- src
|
// Move not found or didn't work so copy dst <- src
|
||||||
|
if origRemote != remote {
|
||||||
|
dst = nil
|
||||||
|
}
|
||||||
newDst, err = Copy(ctx, fdst, dst, origRemote, src)
|
newDst, err = Copy(ctx, fdst, dst, origRemote, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Errorf(src, "Not deleting source as copy failed: %v", err)
|
fs.Errorf(src, "Not deleting source as copy failed: %v", err)
|
||||||
|
@ -437,6 +437,36 @@ func TestTransformFile(t *testing.T) {
|
|||||||
r.CheckRemoteListing(t, []fstest.Item{fstest.NewItem("toe/toe/toe.txt", "hello world", t1)}, []string{"tictacempty_dir", "tictactoe", "tictactoe/tictactoe", "toe", "toe/toe"})
|
r.CheckRemoteListing(t, []fstest.Item{fstest.NewItem("toe/toe/toe.txt", "hello world", t1)}, []string{"tictacempty_dir", "tictactoe", "tictactoe/tictactoe", "toe", "toe/toe"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestManualTransformFile(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
r := fstest.NewRun(t)
|
||||||
|
|
||||||
|
r.Flocal.Features().DisableList([]string{"Copy", "Move"})
|
||||||
|
r.Fremote.Features().DisableList([]string{"Copy", "Move"})
|
||||||
|
|
||||||
|
err := transform.SetOptions(ctx, "all,prefix=tac", "all,prefix=tic")
|
||||||
|
require.NoError(t, err)
|
||||||
|
r.WriteFile("toe/toe/toe.txt", "hello world", t1)
|
||||||
|
_, err = operations.MkdirModTime(ctx, r.Flocal, "empty_dir", t1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
ctx = predictDstFromLogger(ctx)
|
||||||
|
err = MoveDir(ctx, r.Fremote, r.Flocal, true, true)
|
||||||
|
testLoggerVsLsf(ctx, r.Fremote, r.Flocal, operations.GetLoggerOpt(ctx).JSON, t)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
r.CheckLocalListing(t, []fstest.Item{}, []string{})
|
||||||
|
r.CheckRemoteListing(t, []fstest.Item{fstest.NewItem("tictactoe/tictactoe/tictactoe.txt", "hello world", t1)}, []string{"tictacempty_dir", "tictactoe", "tictactoe/tictactoe"})
|
||||||
|
|
||||||
|
err = transform.SetOptions(ctx, "all,trimprefix=tic", "all,trimprefix=tac")
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = operations.TransformFile(ctx, r.Fremote, "tictactoe/tictactoe/tictactoe.txt")
|
||||||
|
require.NoError(t, err)
|
||||||
|
r.CheckLocalListing(t, []fstest.Item{}, []string{})
|
||||||
|
r.CheckRemoteListing(t, []fstest.Item{fstest.NewItem("toe/toe/toe.txt", "hello world", t1)}, []string{"tictacempty_dir", "tictactoe", "tictactoe/tictactoe", "toe", "toe/toe"})
|
||||||
|
}
|
||||||
|
|
||||||
func TestBase64(t *testing.T) {
|
func TestBase64(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
|
Reference in New Issue
Block a user