@@ -339,11 +339,6 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
339
339
fromHash , err = gitutil .GetHEAD (reposPath )
340
340
if err != nil {
341
341
result := errors .New ("failed to get HEAD commit hash: " + err .Error ())
342
- logger .Debug ("Rollbacking " + fullReposPath + " ..." )
343
- err = cmd .rollbackRepos (fullReposPath )
344
- if err != nil {
345
- result = multierror .Append (result , err )
346
- }
347
342
done <- getParallelResult {
348
343
reposPath : reposPath ,
349
344
status : fmt .Sprintf (fmtInstallFailed , reposPath ),
@@ -372,11 +367,6 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
372
367
err := cmd .upgradePlugin (reposPath , cfg )
373
368
if err != git .NoErrAlreadyUpToDate && err != nil {
374
369
result := errors .New ("failed to upgrade plugin: " + err .Error ())
375
- logger .Debug ("Rollbacking " + fullReposPath + " ..." )
376
- err = cmd .rollbackRepos (fullReposPath )
377
- if err != nil {
378
- result = multierror .Append (result , err )
379
- }
380
370
done <- getParallelResult {
381
371
reposPath : reposPath ,
382
372
status : fmt .Sprintf (fmtUpgradeFailed , reposPath ),
@@ -396,7 +386,7 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
396
386
if err != nil {
397
387
result := errors .New ("failed to install plugin: " + err .Error ())
398
388
logger .Debug ("Rollbacking " + fullReposPath + " ..." )
399
- err = cmd .rollbackRepos (fullReposPath )
389
+ err = cmd .removeDir (fullReposPath )
400
390
if err != nil {
401
391
result = multierror .Append (result , err )
402
392
}
@@ -420,10 +410,12 @@ func (cmd *getCmd) installPlugin(reposPath pathutil.ReposPath, repos *lockjson.R
420
410
toHash , err = gitutil .GetHEAD (reposPath )
421
411
if err != nil {
422
412
result := errors .New ("failed to get HEAD commit hash: " + err .Error ())
423
- logger .Debug ("Rollbacking " + fullReposPath + " ..." )
424
- err = cmd .rollbackRepos (fullReposPath )
425
- if err != nil {
426
- result = multierror .Append (result , err )
413
+ if doInstall {
414
+ logger .Debug ("Rollbacking " + fullReposPath + " ..." )
415
+ err = cmd .removeDir (fullReposPath )
416
+ if err != nil {
417
+ result = multierror .Append (result , err )
418
+ }
427
419
}
428
420
done <- getParallelResult {
429
421
reposPath : reposPath ,
@@ -460,12 +452,14 @@ func (cmd *getCmd) installPlugconf(reposPath pathutil.ReposPath, pluginResult *g
460
452
err := cmd .fetchPlugconf (reposPath )
461
453
if err != nil {
462
454
result := errors .New ("failed to install plugconf: " + err .Error ())
463
- fullReposPath := pathutil .FullReposPath (reposPath )
464
- logger .Debug ("Rollbacking " + fullReposPath + " ..." )
465
- err = cmd .rollbackRepos (fullReposPath )
466
- if err != nil {
467
- result = multierror .Append (result , err )
468
- }
455
+ // TODO: Call cmd.removeDir() only when the repos *did not* exist previously
456
+ // and was installed newly.
457
+ // fullReposPath := pathutil.FullReposPath(reposPath)
458
+ // logger.Debug("Rollbacking " + fullReposPath + " ...")
459
+ // err = cmd.removeDir(fullReposPath)
460
+ // if err != nil {
461
+ // result = multierror.Append(result, err)
462
+ // }
469
463
done <- getParallelResult {
470
464
reposPath : reposPath ,
471
465
status : fmt .Sprintf (fmtInstallFailed , reposPath ),
@@ -486,7 +480,7 @@ func (*getCmd) detectReposType(fullpath string) (lockjson.ReposType, error) {
486
480
return lockjson .ReposStaticType , nil
487
481
}
488
482
489
- func (* getCmd ) rollbackRepos (fullReposPath string ) error {
483
+ func (* getCmd ) removeDir (fullReposPath string ) error {
490
484
if pathutil .Exists (fullReposPath ) {
491
485
err := os .RemoveAll (fullReposPath )
492
486
if err != nil {
0 commit comments