case 4694 - standalone setup stops a running embedded PostgreSQL first

The 8.2.4 and older launchers left PostgreSQL running after the in-app
shutdown, so every standalone upgrade stopped at "files in use" and could not
close it. PrepareToInstall and uninstall now run the installed pg_ctl stop.
Changelog; BUILD.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 21:45:39 -07:00
parent 7959ad9cec
commit 450acc5ef7
4 changed files with 24 additions and 3 deletions

View File

@@ -87,8 +87,28 @@ Filename: "{sys}\icacls.exe"; Parameters: """{app}"" /remove:g *S-1-5-32-545 /T
Filename: "{app}\launcher\ayanova-launcher.exe"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
// case 4694: the launcher of 8.2.4 and older left the local PostgreSQL server running when AyaNova was shut down, so
// its files are in use; stop it (if running) before installing over it or uninstalling
procedure StopLocalPostgres();
var
PgCtl: String;
ResultCode: Integer;
begin
PgCtl := ExpandConstant('{app}\local-postgres\bin\pg_ctl.exe');
if FileExists(PgCtl) and DirExists(ExpandConstant('{commonappdata}\ayanova\database')) then
Exec(PgCtl, 'stop -D "' + ExpandConstant('{commonappdata}\ayanova\database') + '" -m fast -w', ExtractFileDir(PgCtl), SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
StopLocalPostgres();
Result := '';
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
StopLocalPostgres();
if CurUninstallStep = usPostUninstall then
begin
if MsgBox('Do you want to delete all AyaNova database, attachment and log files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then