From 894c3fc625b21bd654956d3151e57cbbb9377408 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Mon, 19 Sep 2016 12:23:53 -0500 Subject: [PATCH] (GH-943) Remove Transaction Lock Even on Failure Whether or not the package is successful, remove the lock on the pending file. Otherwise the failed install cleanup will not work properly. --- .../services/ChocolateyPackageService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 9e8f5ab478..7c98ab7257 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -412,6 +412,8 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu ensure_bad_package_path_is_clean(config, packageResult); EventManager.publish(new HandlePackageResultCompletedMessage(packageResult, config, commandName)); + remove_pending(packageResult, config); + if (!packageResult.Success) { this.Log().Error(ChocolateyLoggers.Important, "The {0} of {1} was NOT successful.".format_with(commandName.to_string(), packageResult.Name)); @@ -421,9 +423,7 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu } remove_rollback_if_exists(packageResult); - - if (packageResult.Success) remove_pending(packageResult, config); - + this.Log().Info(ChocolateyLoggers.Important, " The {0} of {1} was successful.".format_with(commandName.to_string(), packageResult.Name)); var installLocation = Environment.GetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyPackageInstallLocation); @@ -1193,7 +1193,7 @@ public void remove_pending(PackageResult packageResult, ChocolateyConfiguration fileLock.Dispose(); } - if (_fileSystem.file_exists(pendingFile)) _fileSystem.delete_file(pendingFile); + if (packageResult.Success && _fileSystem.file_exists(pendingFile)) _fileSystem.delete_file(pendingFile); } private IEnumerable get_environment_before(ChocolateyConfiguration config, bool allowLogging = true)