Skip to content

Commit 894c3fc

Browse files
committed
(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.
1 parent 3f19e0f commit 894c3fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
412412
ensure_bad_package_path_is_clean(config, packageResult);
413413
EventManager.publish(new HandlePackageResultCompletedMessage(packageResult, config, commandName));
414414

415+
remove_pending(packageResult, config);
416+
415417
if (!packageResult.Success)
416418
{
417419
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
421423
}
422424

423425
remove_rollback_if_exists(packageResult);
424-
425-
if (packageResult.Success) remove_pending(packageResult, config);
426-
426+
427427
this.Log().Info(ChocolateyLoggers.Important, " The {0} of {1} was successful.".format_with(commandName.to_string(), packageResult.Name));
428428

429429
var installLocation = Environment.GetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyPackageInstallLocation);
@@ -1193,7 +1193,7 @@ public void remove_pending(PackageResult packageResult, ChocolateyConfiguration
11931193
fileLock.Dispose();
11941194
}
11951195

1196-
if (_fileSystem.file_exists(pendingFile)) _fileSystem.delete_file(pendingFile);
1196+
if (packageResult.Success && _fileSystem.file_exists(pendingFile)) _fileSystem.delete_file(pendingFile);
11971197
}
11981198

11991199
private IEnumerable<GenericRegistryValue> get_environment_before(ChocolateyConfiguration config, bool allowLogging = true)

0 commit comments

Comments
 (0)