Skip to content

Commit 011c4f9

Browse files
committed
update inno updater, selectively launch code after update
1 parent 460e00c commit 011c4f9

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

build/win32/code.iss

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ Name: "simplifiedChinese"; MessagesFile: "{#RepoDir}\build\win32\i18n\Default.zh
4747
Name: "traditionalChinese"; MessagesFile: "{#RepoDir}\build\win32\i18n\Default.zh-tw.isl,{#RepoDir}\build\win32\i18n\messages.zh-tw.isl" {#LocalizedLanguageFile("cht")}
4848

4949
[InstallDelete]
50-
Type: filesandordirs; Name: "{app}\resources\app\out"
51-
Type: filesandordirs; Name: "{app}\resources\app\plugins"
52-
Type: filesandordirs; Name: "{app}\resources\app\extensions"
53-
Type: filesandordirs; Name: "{app}\resources\app\node_modules"
54-
Type: files; Name: "{app}\resources\app\Credits_45.0.2454.85.html"
50+
Type: filesandordirs; Name: "{app}\resources\app\out"; Check: IsNotUpdate
51+
Type: filesandordirs; Name: "{app}\resources\app\plugins"; Check: IsNotUpdate
52+
Type: filesandordirs; Name: "{app}\resources\app\extensions"; Check: IsNotUpdate
53+
Type: filesandordirs; Name: "{app}\resources\app\node_modules"; Check: IsNotUpdate
54+
Type: files; Name: "{app}\resources\app\Credits_45.0.2454.85.html"; Check: IsNotUpdate
5555

5656
[UninstallDelete]
5757
Type: filesandordirs; Name: "{app}\_"
@@ -76,7 +76,7 @@ Name: "{commondesktop}\{#NameLong}"; Filename: "{app}\{#ExeBasename}.exe"; Tasks
7676
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#NameLong}"; Filename: "{app}\{#ExeBasename}.exe"; Tasks: quicklaunchicon; AppUserModelID: "{#AppUserId}"
7777

7878
[Run]
79-
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Tasks: runcode; Flags: nowait postinstall; Check: WizardSilent
79+
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Tasks: runcode; Flags: nowait postinstall; Check: ShouldRunAfterUpdate
8080
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Flags: nowait postinstall; Check: WizardNotSilent
8181

8282
[Registry]
@@ -963,7 +963,23 @@ end;
963963
// Updates
964964
function IsUpdate(): Boolean;
965965
begin
966-
Result := ExpandConstant('{param:update|false}') = 'true';
966+
Result := ExpandConstant('{param:update|false}') <> 'false';
967+
end;
968+
969+
function IsNotUpdate(): Boolean;
970+
begin
971+
Result := not IsUpdate();
972+
end;
973+
974+
// VS Code will create a flag file before the update starts (/update=C:\foo\bar)
975+
// - if the file exists at this point, the user quit Code before the update finished, so don't start Code after update
976+
// - otherwise, the user has accepted to apply the update and Code should start
977+
function ShouldRunAfterUpdate(): Boolean;
978+
begin
979+
if IsUpdate() then
980+
Result := not FileExists(ExpandConstant('{param:update}'))
981+
else
982+
Result := False;
967983
end;
968984
969985
function GetAppMutex(Value: string): string;
@@ -986,7 +1002,7 @@ procedure CurStepChanged(CurStep: TSetupStep);
9861002
var
9871003
UpdateResultCode: Integer;
9881004
begin
989-
if (CurStep = ssPostInstall) and (ExpandConstant('{param:update|false}') = 'true') then
1005+
if IsUpdate() and (CurStep = ssPostInstall) then
9901006
begin
9911007
CreateMutex('{#AppMutex}-ready');
9921008
@@ -996,12 +1012,7 @@ begin
9961012
Sleep(1000);
9971013
end;
9981014
999-
Sleep(1000);
1000-
1001-
if Exec(ExpandConstant('{app}\inno_updater.exe'), ExpandConstant('--apply-update _ "{app}\unins000.dat"'), '', SW_SHOW, ewWaitUntilTerminated, UpdateResultCode) then
1002-
Log('Update applied successfully!')
1003-
else
1004-
Log('Failed to apply update!');
1015+
Exec(ExpandConstant('{app}\inno_updater.exe'), ExpandConstant('--apply-update _ "{app}\unins000.dat"'), '', SW_SHOW, ewWaitUntilTerminated, UpdateResultCode);
10051016
end;
10061017
end;
10071018

build/win32/inno_updater.exe

2 KB
Binary file not shown.

0 commit comments

Comments
 (0)