Skip to content

Commit

Permalink
Add check for GCS file upload exist (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
chowbao authored Aug 29, 2024
1 parent e82c6e5 commit e72e367
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/upload_to_gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ func (g *GCS) UploadTo(credentialsPath, bucket, path string) error {
return err
}

// This is a possibly redundant check to make sure that the file is actually
// uploaded to GCS and is readable
pathObj := client.Bucket(bucket).Object(path)
_, err = pathObj.Attrs(ctx)
if err != nil {
return fmt.Errorf("uploaded file does not exist: %v", err)
}

cmdLogger.Infof("Successfully uploaded %d bytes to gs://%s/%s", written, bucket, path)

deleteLocalFiles(path)
Expand Down

0 comments on commit e72e367

Please sign in to comment.