From 52ebfd703c946ea331eeb67f85af36e95a21aa4a Mon Sep 17 00:00:00 2001 From: Timothy <74168694+chengt-ing@users.noreply.github.com> Date: Sun, 19 May 2024 23:18:03 +0800 Subject: [PATCH] fix: update resource with id (#3405) * chore: update presign expires * fix: update resource with id --------- Co-authored-by: timothy --- server/service/s3_object_presigner/s3_object_presigner.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/service/s3_object_presigner/s3_object_presigner.go b/server/service/s3_object_presigner/s3_object_presigner.go index f40615e7..29164bd8 100644 --- a/server/service/s3_object_presigner/s3_object_presigner.go +++ b/server/service/s3_object_presigner/s3_object_presigner.go @@ -45,9 +45,9 @@ func (p *S3ObjectPresigner) CheckAndPresign(ctx context.Context) { } if s3ObjectPayload.LastPresignedTime != nil { - // Skip if the presigned URL is still valid for the next 6 days. - // The default expiration time is 7 days. - if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(6 * 24 * time.Hour)) { + // Skip if the presigned URL is still valid for the next 4 days. + // The expiration time is set to 5 days. + if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(4 * 24 * time.Hour)) { continue } } @@ -74,6 +74,7 @@ func (p *S3ObjectPresigner) CheckAndPresign(ctx context.Context) { s3ObjectPayload.S3Config = s3Config s3ObjectPayload.LastPresignedTime = timestamppb.New(time.Now()) if err := p.Store.UpdateResource(ctx, &store.UpdateResource{ + ID: resource.ID, Reference: &presignURL, Payload: &storepb.ResourcePayload{ Payload: &storepb.ResourcePayload_S3Object_{