ignore errors getting current object retention, since this 404s if it doesn't have one

This commit is contained in:
nyanotech 2024-04-04 22:59:49 -07:00
parent 301f1c8ed6
commit 19c5d485ae
Signed by: nyanotech
GPG Key ID: D2D0A9E8F160472B

View File

@ -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,