@@ -83,7 +83,8 @@ type DeployOptions struct {
8383 BuildDir string
8484 LargeMediaEnabled bool
8585
86- IsDraft bool
86+ IsDraft bool
87+ SkipRetry bool
8788
8889 Title string
8990 Branch string
@@ -344,12 +345,14 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
344345 return deploy , nil
345346 }
346347
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 {
348351 return nil , err
349352 }
350353
351354 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 {
353356 return nil , err
354357 }
355358 }
@@ -401,7 +404,7 @@ func (n *Netlify) WaitUntilDeployLive(ctx context.Context, d *models.Deploy) (*m
401404 return n .waitForState (ctx , d , "ready" )
402405}
403406
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 {
405408 sharedErr := & uploadError {err : nil , mutex : & sync.Mutex {}}
406409 sem := make (chan int , n .uploadLimit )
407410 wg := & sync.WaitGroup {}
@@ -431,7 +434,7 @@ func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *depl
431434 select {
432435 case sem <- 1 :
433436 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 )
435438 case <- ctx .Done ():
436439 log .Info ("Context terminated, aborting file upload" )
437440 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
451454 return sharedErr .err
452455}
453456
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 ) {
455458 defer func () {
456459 wg .Done ()
457460 <- sem
@@ -545,7 +548,7 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
545548 sharedErr .mutex .Unlock ()
546549 }
547550
548- if apiErr .Code () == 400 || apiErr .Code () == 422 {
551+ if skipRetry && ( apiErr .Code () == 400 || apiErr .Code () == 422 ) {
549552 sharedErr .mutex .Lock ()
550553 sharedErr .err = operationError
551554 sharedErr .mutex .Unlock ()
0 commit comments