Skip to content

Commit 1ce3080

Browse files
committed
handle pseudo-directories correctly for Swift sources
Closes #25.
1 parent 65f6e30 commit 1ce3080

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Changes:
1111
Old: DEBUG: skipping /files/1.txt: is not included by `[0-9].txt`
1212
New: DEBUG: skipping /files/1.txt: /files/ is not included by `[0-9].txt`
1313

14+
Bugfixes:
15+
- When using a Swift source, pseudo-directories are now recognized and transferred correctly.
16+
1417
# v2.4.0 (2018-06-14)
1518

1619
New features:

pkg/objects/swift.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ func (s *SwiftLocation) Connect() error {
164164
func (s *SwiftLocation) ObjectAtPath(path string) *schwift.Object {
165165
objectName := strings.TrimPrefix(path, "/")
166166
if s.ObjectNamePrefix != "" {
167+
isPseudoDir := strings.HasSuffix(objectName, "/")
167168
objectName = filepath.Join(s.ObjectNamePrefix, objectName)
169+
if isPseudoDir {
170+
objectName += "/"
171+
}
168172
}
169173
return s.Container.Object(objectName)
170174
}

tests.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,35 @@ This file does not get cleaned up because it's not below object_prefix.
562562
Hello World.
563563
EOF
564564

565+
################################################################################
566+
step 'Test 11: Swift sources with pseudo-directories'
567+
568+
if [ "$1" = http ]; then
569+
echo ">> Test skipped (works only with Swift source)."
570+
else
571+
572+
upload_file_from_stdin pseudo/directory/ < /dev/null
573+
upload_file_from_stdin pseudo/regularfile.txt <<-EOF
574+
Hello File.
575+
EOF
576+
577+
mirror <<-EOF
578+
swift: { $AUTH_PARAMS }
579+
jobs:
580+
- from: ${SOURCE_SPEC}
581+
to:
582+
container: ${CONTAINER_BASE}-test11
583+
only: pseudo/
584+
EOF
585+
586+
expect test11 <<-EOF
587+
>> pseudo/directory/
588+
>> pseudo/regularfile.txt
589+
Hello File.
590+
EOF
591+
592+
fi # end of: if [ "$1" = http ]
593+
565594
################################################################################
566595
# cleanup before exiting
567596

0 commit comments

Comments
 (0)