GoogleCloudPlatform/gsutil

gsutil mv seems to delete my file rather than renaming?

not-a-doctor-stromberg opened this issue · 3 comments

This command seems to delete my file rather than rename it:

$ gsutil mv gs://my-bucket/a-file.csv gs://my-bucket/renamed.csv

Copying gs://my-bucket/a-file.csv [Content-Type=text/csv]...
Removing gs://my-bucket/a-file.csv...

Operation completed over 1 objects/420.0 B.

Version:

gsutil version: 5.12

System:

Darwin Aarons-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64

The final result is that the object is deleted. I have object versioning enabled however, and if I restore the file, the file is restored as renamed.csv. Am I doing something wrong here? I expected that the file would simply be renamed.

Moving is a 2-step process, first the object/file is copied to the new location and then deleted in the old location. Are you saying that after running your command, you don't see gs://my-bucket/renamed.csv?

Correct. It only appears after I restore the deleted object and then it is restored with the new name.

I am a dingus. A part of our system was moving the file after it was renamed so it appeared to be gone. It still seems interesting though that when the deleted object is restored it has the new name, but I will close this as "issue author is a dingus". Thank you!