diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go index 6e3177053..cef381693 100644 --- a/core/storageproviders/s3Storage.go +++ b/core/storageproviders/s3Storage.go @@ -200,7 +200,9 @@ func (s *S3Storage) Cleanup() error { return err } - s.deleteObjects(keys) + if len(keys) > 0 { + s.deleteObjects(keys) + } return nil } @@ -241,6 +243,10 @@ func (s *S3Storage) getDeletableVideoSegmentsWithOffset(offset int) ([]s3object, return nil, err } + if offset > len(objectsToDelete)-1 { + offset = len(objectsToDelete) - 1 + } + objectsToDelete = objectsToDelete[offset : len(objectsToDelete)-1] return objectsToDelete, nil