From f8ba4096f603887aecd16d798bdeda3f538889f4 Mon Sep 17 00:00:00 2001 From: Caleb Brown Date: Fri, 11 Nov 2022 17:23:23 +1100 Subject: [PATCH] Only write to the rawBucket if the value exists. Signed-off-by: Caleb Brown --- cron/internal/controller/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cron/internal/controller/main.go b/cron/internal/controller/main.go index 628a25894cf..8030e2d4f33 100644 --- a/cron/internal/controller/main.go +++ b/cron/internal/controller/main.go @@ -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)) + } } }