From 8369b5209fc602a87e319adc59e5c536042c89c4 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 2 Dec 2015 21:23:56 +0000 Subject: [PATCH] swift: Make sure we read the size for 0 length files - Fixes #237 This was causing a problem with sync for chunked files. The directory listing would read their size back as 0 and see that the size had changed and immediately resync it. --- swift/swift.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/swift/swift.go b/swift/swift.go index 6e98c03ff..f3662abdf 100644 --- a/swift/swift.go +++ b/swift/swift.go @@ -210,6 +210,12 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *swift.Object) fs.Object { fs: f, remote: remote, } + // Note that due to a quirk of swift, manifest files are + // returned as 0 bytes in the listing. Correct this here by + // making sure we read the full metadata for all 0 byte files. + if info != nil && info.Bytes == 0 { + info = nil + } if info != nil { // Set info but not headers o.info = *info @@ -537,9 +543,8 @@ func (o *Object) SetModTime(modTime time.Time) { // Storable returns if this object is storable // -// It reads the metadata for <= directoryMarkerMaxSize byte objects then compares the -// Content-Type to directoryMarkerContentType - that makes it a -// directory marker which is not storable. +// It compares the Content-Type to directoryMarkerContentType - that +// makes it a directory marker which is not storable. func (o *Object) Storable() bool { return o.info.ContentType != directoryMarkerContentType }