From 6d99681b8d933dfe11741d1a58de68cdb85c82d1 Mon Sep 17 00:00:00 2001 From: salt_build Date: Wed, 8 Apr 2015 18:25:56 +0000 Subject: [PATCH] Moved file deletion to happen after user clicks install --- pkg/windows/installer/Salt-Minion-Setup.nsi | 64 +++++++++++---------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/pkg/windows/installer/Salt-Minion-Setup.nsi b/pkg/windows/installer/Salt-Minion-Setup.nsi index c40afc9f9d..8261b11a01 100644 --- a/pkg/windows/installer/Salt-Minion-Setup.nsi +++ b/pkg/windows/installer/Salt-Minion-Setup.nsi @@ -193,7 +193,39 @@ SectionEnd Section "MainSection" SEC01 - ExecWait "net stop salt-minion" ;stopping service before upgrading + ; Remove previous version of salt, but don't remove conf and key + ; Service must be stopped to delete files that are in use + ExecWait "net stop salt-minion" + ; Remove the service in case we're installing over an older version + ; It will be recreated later + ExecWait "sc delete salt-minion" + + ; Delete everything except conf and var + ClearErrors + FindFirst $0 $1 $INSTDIR\* + + loop: + IfFileExists "$INSTDIR\$1\*.*" IsDir IsFile + + IsDir: + ${IfNot} $1 == "." + ${AndIfNot} $1 == ".." + ${AndIfNot} $1 == "conf" + ${AndIfNot} $1 == "var" + RMDir /r "$INSTDIR\$1" + ${EndIf} + + IsFile: + DELETE "$INSTDIR\$1" + + FindNext $0 $1 + IfErrors done + + Goto loop + + done: + FindClose $0 + Sleep 3000 SetOutPath "$INSTDIR\" SetOverwrite try @@ -291,36 +323,6 @@ Function .onInit Pop $R1 Pop $R0 - ; Remove previous version of salt, but don't remove conf and key - ExecWait "net stop salt-minion" - ExecWait "sc delete salt-minion" - - ; Delete everything except conf and var - ClearErrors - FindFirst $0 $1 $INSTDIR\* - - loop: - IfFileExists "$INSTDIR\$1\*.*" IsDir IsFile - - IsDir: - ${IfNot} $1 == "." - ${AndIfNot} $1 == ".." - ${AndIfNot} $1 == "conf" - ${AndIfNot} $1 == "var" - RMDir /r "$INSTDIR\$1" - ${EndIf} - - IsFile: - DELETE "$INSTDIR\$1" - - FindNext $0 $1 - IfErrors done - - Goto loop - - done: - FindClose $0 - FunctionEnd Function Trim