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.
s3-about
Nick Craig-Wood 2015-12-02 21:23:56 +00:00
parent 2aa3c0a2af
commit 8369b5209f
1 changed files with 8 additions and 3 deletions

View File

@ -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
}