From b86fa15dbce58df7be87035ae8cac6cd3f4ee98a Mon Sep 17 00:00:00 2001 From: Paresh More Date: Mon, 10 Apr 2017 12:05:09 +0100 Subject: [PATCH] Ensure the web/ directory is cleared before upgrading Windows installations. Fixes #2187 --- pkg/win32/installer.iss.in | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pkg/win32/installer.iss.in b/pkg/win32/installer.iss.in index 42dff254f..4b939a8ed 100644 --- a/pkg/win32/installer.iss.in +++ b/pkg/win32/installer.iss.in @@ -81,4 +81,46 @@ begin Result := True; end; +// This function would be called during upgrade mode +// In upgrade mode - delete web/* and exclude config_local.py +procedure DelWebfolder(Path: string); +var + FindRec: TFindRec; + FilePath: string; +begin + if FindFirst(Path + '\*', FindRec) then + begin + try + repeat + if (FindRec.Name <> '.') and (FindRec.Name <> '..') then + begin + FilePath := Path + '\' + FindRec.Name; + if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then + begin + if CompareText(FindRec.Name, 'config_local.py') <> 0 then + begin + DeleteFile(FilePath); + end + end + else + begin + DelWebfolder(FilePath); + RemoveDir(FilePath); + end + end; + until not FindNext(FindRec); + finally + FindClose(FindRec); + end + end +end; + +procedure CurPageChanged(CurPageID: Integer); +begin + if CurPageID=wpReady then + begin + DelWebfolder(ExpandConstant('{app}\web')); + end +end; + // End of program