From 0ea5db228df6cb0ef755947c362662c42b99d055 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Mon, 25 Mar 2024 08:27:39 -0700 Subject: [PATCH] fix: scoutfs return correct ContentRange for get request --- backend/scoutfs/scoutfs.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/scoutfs/scoutfs.go b/backend/scoutfs/scoutfs.go index 97c2fab..9b24836 100644 --- a/backend/scoutfs/scoutfs.go +++ b/backend/scoutfs/scoutfs.go @@ -457,6 +457,13 @@ func (s *ScoutFS) GetObject(_ context.Context, input *s3.GetObjectInput, writer return nil, err } + objSize := fi.Size() + if fi.IsDir() { + // directory objects are always 0 len + objSize = 0 + length = 0 + } + if length == -1 { length = fi.Size() - startOffset + 1 } @@ -465,6 +472,11 @@ func (s *ScoutFS) GetObject(_ context.Context, input *s3.GetObjectInput, writer return nil, s3err.GetAPIError(s3err.ErrInvalidRequest) } + var contentRange string + if acceptRange != "" { + contentRange = fmt.Sprintf("bytes %v-%v/%v", startOffset, startOffset+length-1, objSize) + } + if s.glaciermode { // Check if there are any offline exents associated with this file. // If so, we will return the InvalidObjectState error. @@ -522,6 +534,7 @@ func (s *ScoutFS) GetObject(_ context.Context, input *s3.GetObjectInput, writer Metadata: userMetaData, TagCount: &tagCount, StorageClass: types.StorageClassStandard, + ContentRange: &contentRange, }, nil }