moveOrCopyFile: avoid panic on --dry-run

Before this change, changing the case of a file on a case insensitive remote
would fatally panic when `--dry-run` was set, due to `moveOrCopyFile`
attempting to access the non-existent `tmpObj` it (would normally have)
created. After this change, the panic is avoided by skipping this step during
a `--dry-run` (with the usual "skipped as --dry-run is set" log message.)
This commit is contained in:
nielash
2023-10-10 07:21:56 -04:00
parent fd95511091
commit 88e516adee
2 changed files with 21 additions and 0 deletions

View File

@ -997,6 +997,23 @@ func TestCaseInsensitiveMoveFile(t *testing.T) {
r.CheckRemoteItems(t, file2Capitalized)
}
func TestCaseInsensitiveMoveFileDryRun(t *testing.T) {
ctx := context.Background()
ctx, ci := fs.AddConfig(ctx)
r := fstest.NewRun(t)
if !r.Fremote.Features().CaseInsensitive {
return
}
ci.DryRun = true
file1 := r.WriteObject(ctx, "hello", "world", t1)
r.CheckRemoteItems(t, file1)
err := operations.MoveFile(ctx, r.Fremote, r.Fremote, "HELLO", file1.Path)
require.NoError(t, err)
r.CheckRemoteItems(t, file1)
}
func TestMoveFileBackupDir(t *testing.T) {
ctx := context.Background()
ctx, ci := fs.AddConfig(ctx)