Ensure the web/ directory is cleared before upgrading Windows installations. Fixes #2187

This commit is contained in:
Paresh More 2017-04-10 12:05:09 +01:00 committed by Dave Page
parent 79e81478e3
commit b86fa15dbc

View File

@ -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