@@ -15,7 +15,6 @@ import (
15
15
"path/filepath"
16
16
"sort"
17
17
"strings"
18
- "sync"
19
18
"time"
20
19
21
20
gcpstorage "cloud.google.com/go/storage"
@@ -366,39 +365,29 @@ func (rs *DirectGCPStorage) Upload(ctx context.Context, source string, name stri
366
365
firstBackup = true
367
366
}
368
367
369
- var wg sync.WaitGroup
370
368
var written int64
371
369
372
- wg .Add (1 )
370
+ wc := obj .NewWriter (ctx )
371
+ wc .Metadata = options .Annotations
372
+ wc .ContentType = options .ContentType
373
+ // Increase chunk size for faster uploading
374
+ wc .ChunkSize = googleapi .DefaultUploadChunkSize * 4
373
375
374
- go func () {
375
- defer wg .Done ()
376
-
377
- wc := obj .NewWriter (ctx )
378
- wc .Metadata = options .Annotations
379
- wc .ContentType = options .ContentType
380
- // Increase chunk size for faster uploading
381
- wc .ChunkSize = googleapi .DefaultUploadChunkSize * 4
382
-
383
- written , err = io .Copy (wc , sfn )
384
- if err != nil {
385
- log .WithError (err ).WithField ("name" , name ).Error ("Error while uploading file" )
386
- return
387
- }
388
-
389
- // persist changes in GCS
390
- err = wc .Close ()
391
- if err != nil {
392
- log .WithError (err ).WithField ("name" , name ).Error ("Error while uploading file" )
393
- return
394
- }
395
- }()
376
+ written , err = io .Copy (wc , sfn )
377
+ if err != nil {
378
+ log .WithError (err ).WithField ("name" , name ).Error ("Error while uploading file" )
379
+ return "" , "" , err
380
+ }
396
381
397
- wg .Wait ()
382
+ // persist changes in GCS
383
+ err = wc .Close ()
384
+ if err != nil {
385
+ log .WithError (err ).WithField ("name" , name ).Error ("Error while uploading file" )
386
+ return "" , "" , err
387
+ }
398
388
399
389
if written != totalSize {
400
- err = xerrors .Errorf ("Wrote fewer bytes than it should have, %d instead of %d" , written , totalSize )
401
- return
390
+ return "" , "" , xerrors .Errorf ("Wrote fewer bytes than it should have, %d instead of %d" , written , totalSize )
402
391
}
403
392
404
393
// maintain backup trail if we're asked to - we do this prior to overwriting the regular backup file
0 commit comments