GoogleCloudPlatform / GoogleCloudPlatform/gsutil
`mv` adds additional subfolder when subfolder exists
- Dominant language
- Python
- Stars
- 918
- Forks
- 335
- PR merge metrics
- No merged PRs in 30d
Description
When `mv` is used to move a file between buckets, it behaves differently depending on whether a subfolder with the same name exists.
## Reproducing steps
1. Create two buckets, `test-bucket` and `test-bucket-2`.
2. Create a temp file in your local dir.
```
touch 12345.txt
```
3. Copy the file to `test-bucket` with the following subfolders.
```
gsutil cp 12345.txt gs://test-bucket/folder/nested_folder/aaaa/bbbb/cccc/12345.txt
```
4. Move file to `test-bucket-2`.
```
gsutil -m mv gs://test-bucket/folder/nested_folder gs://test-bucket-2/folder/nested_folder
```
5. Check the contents of `test-bucket-2`.
```
gsutil ls "gs://test-bucket-2/folder/nested_folder/**"
```
First Output should be as follows:
```
gs://test-bucket-2/folder/nested_folder/aaaa/bbbb/cccc/12345.txt
```
6. Repeat the step 3, 4 and 5. Check that output of `step 5` included a secondary `nested_folder` in it.
```
gs://test-bucket-2/folder/nested_folder/aaaa/bbbb/cccc/12345.txt
gs://test-bucket-2/folder/nested_folder/nested_folder/aaaa/bbbb/cccc/12345.txt
```
I am not sure if this is an expected behavior but same command producing two different results depending on the bucket structure does not feel right.
Contributor guide
Research direction
Start by reproducing the documented sequence with gsutil -m mv, including the second move after the destination subfolder exists. Trace the mv destination-path handling for existing subfolders, then verify that repeated moves do not add a duplicate nested_folder and add regression coverage for the reproduced case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, python
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100