From ecd1512edf6ee70fccbf066b32bd365e93288771 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 4 Feb 2015 01:04:23 -0600 Subject: [PATCH] (GH-7) Do not error on removing choco.exe.old It could be that there are two running instances of choco going at the same time during upgrade scenarios, so throwing a fatal error would be a bad thing. --- src/chocolatey.console/Program.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/chocolatey.console/Program.cs b/src/chocolatey.console/Program.cs index 5bd2b7ceb9..54bc2bf16a 100644 --- a/src/chocolatey.console/Program.cs +++ b/src/chocolatey.console/Program.cs @@ -137,8 +137,15 @@ private static void Main(string[] args) private static void remove_old_chocolatey_exe(IFileSystem fileSystem) { - fileSystem.delete_file(Assembly.GetExecutingAssembly().Location + ".old"); - fileSystem.delete_file(fileSystem.combine_paths(AppDomain.CurrentDomain.BaseDirectory, "choco.exe.old")); + try + { + fileSystem.delete_file(Assembly.GetExecutingAssembly().Location + ".old"); + fileSystem.delete_file(fileSystem.combine_paths(AppDomain.CurrentDomain.BaseDirectory, "choco.exe.old")); + } + catch (Exception ex) + { + "chocolatey".Log().Warn("Attempting to delete choco.exe.old ran into an issue:{0} {1}".format_with(Environment.NewLine,ex.Message)); + } } private static void pause_execution_if_debug()