From b82436bff554bc435b2a515cce28a4f561441c35 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 4 Jun 2015 09:57:41 -0500 Subject: [PATCH] (GH-304) Auto Installer allow system cleanup If the preceeding chocolatelyUninstall.ps1 uninstalls an application, sometimes the system is still cleaning up files and registry keys. Those keys are found by the auto installer and it decides to also move forward with the uninstall. In cases like that, the auto uninstaller should wait a few seconds before moving forward with checks. --- .../services/AutomaticUninstallerService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs index 35ed3932bd..638b953869 100644 --- a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs +++ b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs @@ -18,6 +18,7 @@ namespace chocolatey.infrastructure.app.services using System; using System.Collections.Generic; using System.Linq; + using System.Threading; using configuration; using domain; using filesystem; @@ -30,6 +31,7 @@ public class AutomaticUninstallerService : IAutomaticUninstallerService private readonly IFileSystem _fileSystem; private readonly IRegistryService _registryService; private readonly ICommandExecutor _commandExecutor; + private const int SLEEP_TIME = 5; public AutomaticUninstallerService(IChocolateyPackageInformationService packageInfoService, IFileSystem fileSystem, IRegistryService registryService, ICommandExecutor commandExecutor) { @@ -63,6 +65,8 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) } this.Log().Info(" Running auto uninstaller..."); + this.Log().Debug("Sleeping for {0} seconds to allow Windows to finish cleaning up.".format_with(SLEEP_TIME)); + Thread.Sleep((int)TimeSpan.FromSeconds(SLEEP_TIME).TotalMilliseconds); foreach (var key in registryKeys.or_empty_list_if_null()) {