From db37360a1d846bb46e83c3e4b40394504257af35 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 10 Jul 2020 11:03:08 +0100 Subject: [PATCH] swift: fix dangling large objects breaking the listing Before this change, large objects which had had their contents deleted would return "Object not found" and break the listing. This change makes these objects appear as 0 sized entities so they can be listed and deleted. --- backend/swift/swift.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/swift/swift.go b/backend/swift/swift.go index c94b79822..8549519b5 100644 --- a/backend/swift/swift.go +++ b/backend/swift/swift.go @@ -505,7 +505,15 @@ func (f *Fs) newObjectWithInfo(remote string, info *swift.Object) (fs.Object, er // making sure we read the full metadata for all 0 byte files. // We don't read the metadata for directory marker objects. if info != nil && info.Bytes == 0 && info.ContentType != "application/directory" { - info = nil + err := o.readMetaData() // reads info and headers, returning an error + if err == fs.ErrorObjectNotFound { + // We have a dangling large object here so just return the original metadata + fs.Errorf(o, "dangling large object with no contents") + } else if err != nil { + return nil, err + } else { + return o, nil + } } if info != nil { // Set info but not headers