@@ -83,7 +83,8 @@ type DeployOptions struct {
83
83
BuildDir string
84
84
LargeMediaEnabled bool
85
85
86
- IsDraft bool
86
+ IsDraft bool
87
+ SkipRetry bool
87
88
88
89
Title string
89
90
Branch string
@@ -344,12 +345,14 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
344
345
return deploy , nil
345
346
}
346
347
347
- if err := n .uploadFiles (ctx , deploy , options .files , options .Observer , fileUpload , options .UploadTimeout ); err != nil {
348
+ skipRetry := options .SkipRetry || false
349
+
350
+ if err := n .uploadFiles (ctx , deploy , options .files , options .Observer , fileUpload , options .UploadTimeout , skipRetry ); err != nil {
348
351
return nil , err
349
352
}
350
353
351
354
if options .functions != nil {
352
- if err := n .uploadFiles (ctx , deploy , options .functions , options .Observer , functionUpload , options .UploadTimeout ); err != nil {
355
+ if err := n .uploadFiles (ctx , deploy , options .functions , options .Observer , functionUpload , options .UploadTimeout , options . SkipRetry ); err != nil {
353
356
return nil , err
354
357
}
355
358
}
@@ -401,7 +404,7 @@ func (n *Netlify) WaitUntilDeployLive(ctx context.Context, d *models.Deploy) (*m
401
404
return n .waitForState (ctx , d , "ready" )
402
405
}
403
406
404
- func (n * Netlify ) uploadFiles (ctx context.Context , d * models.Deploy , files * deployFiles , observer DeployObserver , t uploadType , timeout time.Duration ) error {
407
+ func (n * Netlify ) uploadFiles (ctx context.Context , d * models.Deploy , files * deployFiles , observer DeployObserver , t uploadType , timeout time.Duration , skipRetry bool ) error {
405
408
sharedErr := & uploadError {err : nil , mutex : & sync.Mutex {}}
406
409
sem := make (chan int , n .uploadLimit )
407
410
wg := & sync.WaitGroup {}
@@ -431,7 +434,7 @@ func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *depl
431
434
select {
432
435
case sem <- 1 :
433
436
wg .Add (1 )
434
- go n .uploadFile (ctx , d , file , observer , t , timeout , wg , sem , sharedErr )
437
+ go n .uploadFile (ctx , d , file , observer , t , timeout , wg , sem , sharedErr , skipRetry )
435
438
case <- ctx .Done ():
436
439
log .Info ("Context terminated, aborting file upload" )
437
440
return errors .Wrap (ctx .Err (), "aborted file upload early" )
@@ -451,7 +454,7 @@ func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *depl
451
454
return sharedErr .err
452
455
}
453
456
454
- func (n * Netlify ) uploadFile (ctx context.Context , d * models.Deploy , f * FileBundle , c DeployObserver , t uploadType , timeout time.Duration , wg * sync.WaitGroup , sem chan int , sharedErr * uploadError ) {
457
+ func (n * Netlify ) uploadFile (ctx context.Context , d * models.Deploy , f * FileBundle , c DeployObserver , t uploadType , timeout time.Duration , wg * sync.WaitGroup , sem chan int , sharedErr * uploadError , skipRetry bool ) {
455
458
defer func () {
456
459
wg .Done ()
457
460
<- sem
@@ -545,7 +548,7 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
545
548
sharedErr .mutex .Unlock ()
546
549
}
547
550
548
- if apiErr .Code () == 400 || apiErr .Code () == 422 {
551
+ if skipRetry && ( apiErr .Code () == 400 || apiErr .Code () == 422 ) {
549
552
sharedErr .mutex .Lock ()
550
553
sharedErr .err = operationError
551
554
sharedErr .mutex .Unlock ()
0 commit comments