From b1cc17ab2647185ece5775847ca6e162ba54aae4 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Thu, 2 Jul 2026 17:36:30 +0200 Subject: [PATCH] Style Signed-off-by: Bryan Frimin --- e2e/trust/trust_center_logo_test.go | 3 +++ pkg/filemanager/s3.go | 12 ++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/e2e/trust/trust_center_logo_test.go b/e2e/trust/trust_center_logo_test.go index 48b701817..39c3c4099 100644 --- a/e2e/trust/trust_center_logo_test.go +++ b/e2e/trust/trust_center_logo_test.go @@ -170,6 +170,7 @@ func TestTrustCenter_LogoFileDownloadURL(t *testing.T) { // redirect) with cache headers, so the stable URL is CDN/browser cacheable. resp, err := http.Get(downloadURL) require.NoError(t, err) + defer func() { _ = resp.Body.Close() }() require.Equal(t, http.StatusOK, resp.StatusCode) @@ -199,6 +200,7 @@ func TestTrustCenter_LogoFileDownloadURL(t *testing.T) { revalidateResp, err := http.DefaultClient.Do(revalidateReq) require.NoError(t, err) + defer func() { _ = revalidateResp.Body.Close() }() assert.Equal(t, http.StatusNotModified, revalidateResp.StatusCode) @@ -214,6 +216,7 @@ func TestTrustCenter_LogoFileDownloadURL(t *testing.T) { sinceResp, err := http.DefaultClient.Do(sinceReq) require.NoError(t, err) + defer func() { _ = sinceResp.Body.Close() }() assert.Equal(t, http.StatusNotModified, sinceResp.StatusCode) diff --git a/pkg/filemanager/s3.go b/pkg/filemanager/s3.go index aad80495e..d8ccca140 100644 --- a/pkg/filemanager/s3.go +++ b/pkg/filemanager/s3.go @@ -30,9 +30,6 @@ import ( "go.probo.inc/probo/pkg/coredata" ) -// FileObject carries a streamed S3 object body plus the metadata needed to set -// HTTP response headers. NotModified is set when the caller's conditional -// request matched the current object, in which case Body is nil. type FileObject struct { Body io.ReadCloser ContentType string @@ -42,9 +39,6 @@ type FileObject struct { NotModified bool } -// FileConditions carries HTTP conditional-request values forwarded to S3 so it -// can answer with 304 Not Modified without transferring the body. Zero values -// are omitted. type FileConditions struct { IfNoneMatch string IfModifiedSince time.Time @@ -100,10 +94,6 @@ func (s *Service) GetFileBytes( return data, nil } -// OpenFile streams an object from S3 without buffering it in memory. Conditional -// request values in conds are forwarded to S3; a 304 Not Modified response is -// surfaced as a FileObject with NotModified set (and a nil Body). The caller -// owns closing Body. func (s *Service) OpenFile( ctx context.Context, file *coredata.File, @@ -116,6 +106,7 @@ func (s *Service) OpenFile( if conds.IfNoneMatch != "" { input.IfNoneMatch = &conds.IfNoneMatch } + if !conds.IfModifiedSince.IsZero() { input.IfModifiedSince = &conds.IfModifiedSince } @@ -140,6 +131,7 @@ func (s *Service) OpenFile( if result.ETag != nil { obj.ETag = *result.ETag } + if result.LastModified != nil { obj.LastModified = *result.LastModified }