Skip to content

Commit

Permalink
Only write to the rawBucket if the value exists. (ossf#2451)
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Brown <[email protected]>

Signed-off-by: Caleb Brown <[email protected]>
Signed-off-by: nathaniel.wert <[email protected]>
  • Loading branch information
calebbrown authored and nathaniel.wert committed Nov 28, 2022
1 parent c0cf001 commit 2f1c194
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cron/internal/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,16 @@ func main() {
panic(fmt.Errorf("error writing to BlobStore: %w", err))
}

// Raw data.
*metadata.ShardLoc = rawBucket + "/" + data.GetBlobFilename("", t)
metadataJSON, err = protojson.Marshal(&metadata)
if err != nil {
panic(fmt.Errorf("error during protojson.Marshal raw: %w", err))
}
err = data.WriteToBlobStore(ctx, rawBucket, data.GetShardMetadataFilename(t), metadataJSON)
if err != nil {
panic(fmt.Errorf("error writing to BlobStore raw: %w", err))
if rawBucket != "" {
// Raw data.
*metadata.ShardLoc = rawBucket + "/" + data.GetBlobFilename("", t)
metadataJSON, err = protojson.Marshal(&metadata)
if err != nil {
panic(fmt.Errorf("error during protojson.Marshal raw: %w", err))
}
err = data.WriteToBlobStore(ctx, rawBucket, data.GetShardMetadataFilename(t), metadataJSON)
if err != nil {
panic(fmt.Errorf("error writing to BlobStore raw: %w", err))
}
}
}

0 comments on commit 2f1c194

Please sign in to comment.