'swift upload bucket directory/' creates objects for empty directories
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-swiftclient |
New
|
Undecided
|
Unassigned |
Bug Description
We have a directory tree with empty directories. When uploading the tree to swift objects are created corresponding to directories that are empty. Directories with contents do not have objects created. This behavior is inconsistent and creates issues on download if a file is uploaded that would be placed in previously empty path as follows:
# Create a directory tree with some empty paths
mkdir -p path1/path1a
mkdir -p path1/path1b
touch path1/path1a/file
# Upload tree to swift
swift upload $bucket --object-name $upload_prefix --skip-identical .
# Add a file to an empty directory
touch path1/path1b/file2
# Upload to swift
swift upload bucket --object-name upload_prefix --skip-identical .
# Download the tree from swift
mkdir out
swift download $bucket --prefix $upload_prefix --remove-prefix --skip-identical --output-dir out
Command failed with error code 1 : Error downloading object 'bucket/
Traceback (most recent call last):
File "./sync_
main()
File "./sync_
args.serial, args.target_
File "./sync_
_download_
File "./sync_
target_
File "/srv2/
raise SwiftSubprocess
swiftlib.
So what has happened is swift created a zero byte object for an empty dir. On download it will create a zero byte *file* for that object. Because someone uploaded an object under the previously-empty path then the download fails because we can't create a directory because swift download has already created a file with the same name due to the empty object.
We've had to pepper our code with `find . -type d -empty -delete` prior to swift upload to avoid this issue but that's a pain.
description: | updated |
description: | updated |