Skip to content

Commit

Permalink
(GH-943) Remove Transaction Lock Even on Failure
Browse files Browse the repository at this point in the history
Whether or not the package is successful, remove the lock on the
pending file. Otherwise the failed install cleanup will not work
properly.
  • Loading branch information
ferventcoder committed Sep 19, 2016
1 parent 3f19e0f commit 894c3fc
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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<GenericRegistryValue> get_environment_before(ChocolateyConfiguration config, bool allowLogging = true)
Expand Down

0 comments on commit 894c3fc

Please sign in to comment.