From 9f96c0d4eae01d06b01cba5c54aa5e3534707c92 Mon Sep 17 00:00:00 2001 From: Julian Lepinski Date: Thu, 3 Aug 2023 03:38:39 -0400 Subject: [PATCH] swift: fix HEADing 0-length objects when --swift-no-large-objects set The Swift backend does not always respect the flag telling it to skip HEADing zero-length objects. This commit fixes that for ls/lsl/lsf. Swift returns zero length for dynamic large object files when they're included in a files lookup, which means that determining their size requires HEADing each file that returns a size of zero. rclone's --swift-no-large-objects instructs rclone that no large objects are present and accordingly rclone should not HEAD files that return zero length. When rclone is performing an ls / lsf / lsl type lookup, however, it continues to HEAD any zero length objects it encounters, even with this flag set. Accordingly, this change causes rclone to respect the flag in these situations. NB: It is worth noting that this will cause rclone to incorrectly report zero length for any dynamic large objects encountered with the --swift-no-large-objects flag set. --- backend/swift/swift.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/swift/swift.go b/backend/swift/swift.go index 85ce87f25..6fbd740ec 100644 --- a/backend/swift/swift.go +++ b/backend/swift/swift.go @@ -561,7 +561,7 @@ func (f *Fs) newObjectWithInfo(ctx context.Context, remote string, info *swift.O // returned as 0 bytes in the listing. Correct this here by // 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" { + if info != nil && info.Bytes == 0 && info.ContentType != "application/directory" && !o.fs.opt.NoLargeObjects { err := o.readMetaData(ctx) // reads info and headers, returning an error if err == fs.ErrorObjectNotFound { // We have a dangling large object here so just return the original metadata