question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling `gsutil mv` on a directory/prefix will incorrectly construct destination object path(s) if the destination prefix is a substring of the source prefix

See original GitHub issue

For example gsutil -m mv gs://bucket/dir/subdir1 gs://bucket/dir/subdir2 sometimes correctly renames to gs://bucket/dir/subdir2, but other times to gs://bucket/dir/subdir2/subdir1

Coulnd’t pinpoint exactly conditions, but it seems it has nothing to do with trailing slashes. In any case there is nothing about such bahaviour in the docs.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
mfschwartzcommented, May 22, 2016

If there’s an existing subdirectory called gs://buciket/dir/subdir2 before you run that mv command it will put subdir1 under subdir2. That is correct behavior - it emulates similar behavior of Unix directory renames. Please see https://cloud.google.com/storage/docs/gsutil/commands/cp#how-names-are-constructed for more details.

2reactions
crunchinesscommented, May 22, 2016

@mfschwartz I understand but this was not the case. I tried it again just to make sure.

$ mkdir dir
$ touch dir/file
$ gsutil cp -r dir gs://bucket/
$ gsutil mv gs://bucket/dir gs://bucket/dir2
$ gsutil ls gs://bucket/dir2
gs://bucket/dir2/dir/

unfortunately, it’s seems to be hard to reproduce though, I ran this once and it misbehaved, but then 3 times it worked as expected (with different names every time)

gsutil version: 4.19

Read more comments on GitHub >

github_iconTop Results From Across the Web

mv - Move/rename objects | Cloud Storage
You can use the gsutil mv command to rename all objects with a given prefix to have a new prefix. For example, the...
Read more >
firebase storage: changing folder (file path)'s name with gsutil
You can use the gsutil mv command to rename all objects with a given prefix to have a new prefix. gsutil mv gs://my_bucket/oldprefix...
Read more >
Ubuntu Manpage: Rclone - syncs your files to cloud storage
Synopsis Moves the contents of the source directory to the destination directory. Rclone will error if the source and destination overlap and the...
Read more >
rclone(1) - Debian Manpages
Source and destination paths are specified by the name you gave the ... Any other string will be used as the share part,...
Read more >
Cloud Storage Go Reference
To create a bucket in Google Cloud Storage, call BucketHandle.Create: ... If a CRC32C is sent, and the data in the destination object...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found