Skip to content

Commit

Permalink
S3Save: adjust logging
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-iohk committed Jan 19, 2024
1 parent 86b8a2e commit 5329c79
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/delegation_backend/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ func writeErrorResponse(app *App, w *http.ResponseWriter, msg string) {
func (ctx *AwsContext) S3Save(objs ObjectsToSave) {
for path, bs := range objs {
fullKey := aws.String(ctx.Prefix + "/" + path)
if strings.Contains(path, "blocks") {
if strings.HasPrefix(path, "blocks/") {
_, err := ctx.Client.HeadObject(ctx.Context, &s3.HeadObjectInput{
Bucket: ctx.BucketName,
Key: fullKey,
})
if err == nil {
ctx.Log.Warnf("S3Save: object already exists, skipping: %s", path)
//block already exists, skipping
continue
}
ctx.Log.Warnf("S3Save: Error encountered but proceeding with save: %s, error: %v", path, err)
if !strings.Contains(err.Error(), "NotFound") {
ctx.Log.Warnf("S3Save: Error when checking if block exists, but will continue with block save: %s, error: %v", path, err)
}
}

ctx.Log.Debugf("S3Save: saving %s", path)
Expand Down

0 comments on commit 5329c79

Please sign in to comment.