From 19c5d485ae2451b0e0e20c2b9cd7d3475417b4a2 Mon Sep 17 00:00:00 2001 From: nyanotech Date: Thu, 4 Apr 2024 22:59:49 -0700 Subject: [PATCH] ignore errors getting current object retention, since this 404s if it doesn't have one --- main.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index e074d23..632288d 100644 --- a/main.go +++ b/main.go @@ -71,15 +71,12 @@ func main() { } func checkAndRenewObjectLock(svc *s3.Client, object string) { - retention, err := svc.GetObjectRetention(context.TODO(), &s3.GetObjectRetentionInput{ + retention, _ := svc.GetObjectRetention(context.TODO(), &s3.GetObjectRetentionInput{ Bucket: bucket, Key: &object, }) - if err != nil { - log.Fatalln("Failed to get retention for", object, err) - } - if retention.Retention.RetainUntilDate.Before(time.Now().Add(time.Second * time.Duration(*updateExpiresWithin))) { + if retention == nil || retention.Retention.RetainUntilDate.Before(time.Now().Add(time.Second * time.Duration(*updateExpiresWithin))) { log.Println("Renewing object lock for object", object) _, err := svc.PutObjectRetention(context.TODO(), &s3.PutObjectRetentionInput{ Bucket: bucket,