@@ -62,13 +62,13 @@ Name: "hungarian"; MessagesFile: "{#RepoDir}\build\win32\i18n\Default.hu.isl,{#R
62
62
Name : " turkish" ; MessagesFile : " compiler:Languages\Turkish.isl,{#RepoDir}\build\win32\i18n\messages.tr.isl" {#LocalizedLanguageFile(" trk" )}
63
63
64
64
[InstallDelete]
65
- Type : filesandordirs ; Name : " {app} \resources\app\out" ; Check : IsNotUpdate
66
- Type : filesandordirs ; Name : " {app} \resources\app\plugins" ; Check : IsNotUpdate
67
- Type : filesandordirs ; Name : " {app} \resources\app\extensions" ; Check : IsNotUpdate
68
- Type : filesandordirs ; Name : " {app} \resources\app\node_modules" ; Check : IsNotUpdate
69
- Type : filesandordirs ; Name : " {app} \resources\app\node_modules.asar.unpacked" ; Check : IsNotUpdate
70
- Type : files ; Name : " {app} \resources\app\node_modules.asar" ; Check : IsNotUpdate
71
- Type : files ; Name : " {app} \resources\app\Credits_45.0.2454.85.html" ; Check : IsNotUpdate
65
+ Type : filesandordirs ; Name : " {app} \resources\app\out" ; Check : IsNotBackgroundUpdate
66
+ Type : filesandordirs ; Name : " {app} \resources\app\plugins" ; Check : IsNotBackgroundUpdate
67
+ Type : filesandordirs ; Name : " {app} \resources\app\extensions" ; Check : IsNotBackgroundUpdate
68
+ Type : filesandordirs ; Name : " {app} \resources\app\node_modules" ; Check : IsNotBackgroundUpdate
69
+ Type : filesandordirs ; Name : " {app} \resources\app\node_modules.asar.unpacked" ; Check : IsNotBackgroundUpdate
70
+ Type : files ; Name : " {app} \resources\app\node_modules.asar" ; Check : IsNotBackgroundUpdate
71
+ Type : files ; Name : " {app} \resources\app\Credits_45.0.2454.85.html" ; Check : IsNotBackgroundUpdate
72
72
73
73
[UninstallDelete]
74
74
Type : filesandordirs ; Name : " {app} \_"
@@ -1299,6 +1299,16 @@ Root: {#SoftwareClassesRootKey}; Subkey: "Software\Classes\Drive\shell\{#RegValu
1299
1299
Root : {#EnvironmentRootKey}; Subkey : " {#EnvironmentKey}" ; ValueType : expandsz ; ValueName : " Path" ; ValueData : " {olddata};{app} \bin" ; Tasks: addtopath; Check : NeedsAddPath(ExpandConstant(' {app} \bin' ))
1300
1300
1301
1301
[Code]
1302
+ function IsBackgroundUpdate (): Boolean;
1303
+ begin
1304
+ Result := ExpandConstant(' {param:update|false}' ) <> ' false' ;
1305
+ end ;
1306
+
1307
+ function IsNotBackgroundUpdate (): Boolean;
1308
+ begin
1309
+ Result := not IsBackgroundUpdate();
1310
+ end ;
1311
+
1302
1312
// Don't allow installing conflicting architectures
1303
1313
function InitializeSetup (): Boolean;
1304
1314
var
@@ -1351,6 +1361,13 @@ begin
1351
1361
MsgBox(' Please uninstall the ' + AltArch + ' -bit version of {#NameShort} before installing this ' + ThisArch + ' -bit version.' , mbInformation, MB_OK);
1352
1362
end ;
1353
1363
end ;
1364
+
1365
+ if IsNotBackgroundUpdate() and CheckForMutexes(' {#TunnelMutex}' ) then
1366
+ begin
1367
+ MsgBox(' {#NameShort} is still running a tunnel. Please stop the tunnel before installing.' , mbInformation, MB_OK);
1368
+ Result := false
1369
+ end ;
1370
+
1354
1371
end ;
1355
1372
1356
1373
function WizardNotSilent (): Boolean;
@@ -1359,14 +1376,44 @@ begin
1359
1376
end ;
1360
1377
1361
1378
// Updates
1362
- function IsBackgroundUpdate (): Boolean;
1379
+
1380
+ var
1381
+ ShouldRestartTunnelService: Boolean;
1382
+
1383
+ procedure StopTunnelServiceIfNeeded ();
1384
+ var
1385
+ StopServiceResultCode: Integer;
1386
+ WaitCounter: Integer;
1363
1387
begin
1364
- Result := ExpandConstant(' {param:update|false}' ) <> ' false' ;
1388
+ ShouldRestartTunnelService := False;
1389
+ if CheckForMutexes(' {#TunnelServiceMutex}' ) then begin
1390
+ // stop the tunnel service
1391
+ Log(' Stopping the tunnel service using ' + ExpandConstant(' "{app}\bin\{#ApplicationName}.cmd"' ));
1392
+ ShellExec(' ' , ExpandConstant(' "{app}\bin\{#ApplicationName}.cmd"' ), ' tunnel service uninstall' , ' ' , SW_HIDE, ewWaitUntilTerminated, StopServiceResultCode);
1393
+
1394
+ Log(' Stopping the tunnel service completed with result code ' + IntToStr(StopServiceResultCode));
1395
+
1396
+ WaitCounter := 10 ;
1397
+ while (WaitCounter > 0 ) and CheckForMutexes(' {#TunnelServiceMutex}' ) do
1398
+ begin
1399
+ Log(' Tunnel service is still running, waiting' );
1400
+ Sleep(500 );
1401
+ WaitCounter := WaitCounter - 1
1402
+ end ;
1403
+ if CheckForMutexes(' {#TunnelServiceMutex}' ) then
1404
+ Log(' Unable to stop tunnel service' )
1405
+ else
1406
+ ShouldRestartTunnelService := True;
1407
+ end
1365
1408
end ;
1366
1409
1367
- function IsNotUpdate (): Boolean;
1410
+
1411
+ // called before the wizard checks for running application
1412
+ function PrepareToInstall (var NeedsRestart: Boolean): String;
1368
1413
begin
1369
- Result := not IsBackgroundUpdate();
1414
+ if IsNotBackgroundUpdate() then
1415
+ StopTunnelServiceIfNeeded();
1416
+ Result := ' '
1370
1417
end ;
1371
1418
1372
1419
// VS Code will create a flag file before the update starts (/update=C:\foo\bar)
@@ -1450,18 +1497,33 @@ end;
1450
1497
procedure CurStepChanged (CurStep: TSetupStep);
1451
1498
var
1452
1499
UpdateResultCode: Integer;
1500
+ StartServiceResultCode: Integer;
1453
1501
begin
1454
- if IsBackgroundUpdate() and ( CurStep = ssPostInstall) then
1502
+ if CurStep = ssPostInstall then
1455
1503
begin
1456
- CreateMutex(' {#AppMutex}-ready' );
1457
-
1458
- while (CheckForMutexes(' {#AppMutex}' )) do
1504
+ if IsBackgroundUpdate() then
1459
1505
begin
1460
- Log(' Application is still running, waiting' );
1461
- Sleep(1000 );
1506
+ CreateMutex(' {#AppMutex}-ready' );
1507
+
1508
+ while (CheckForMutexes(' {#AppMutex}' )) do
1509
+ begin
1510
+ Log(' Application is still running, waiting' );
1511
+ Sleep(1000 )
1512
+ end ;
1513
+
1514
+ StopTunnelServiceIfNeeded();
1515
+
1516
+ Exec(ExpandConstant(' {app}\tools\inno_updater.exe' ), ExpandConstant(' "{app}\{#ExeBasename}.exe" ' + BoolToStr(LockFileExists())), ' ' , SW_SHOW, ewWaitUntilTerminated, UpdateResultCode);
1462
1517
end ;
1463
1518
1464
- Exec(ExpandConstant(' {app}\tools\inno_updater.exe' ), ExpandConstant(' "{app}\{#ExeBasename}.exe" ' + BoolToStr(LockFileExists())), ' ' , SW_SHOW, ewWaitUntilTerminated, UpdateResultCode);
1519
+ if ShouldRestartTunnelService then
1520
+ begin
1521
+ // start the tunnel service
1522
+ Log(' Restarting the tunnel service...' );
1523
+ ShellExec(' ' , ExpandConstant(' "{app}\bin\{#ApplicationName}.cmd"' ), ' tunnel service install' , ' ' , SW_HIDE, ewWaitUntilTerminated, StartServiceResultCode);
1524
+ Log(' Starting the tunnel service completed with result code ' + IntToStr(StartServiceResultCode));
1525
+ ShouldRestartTunnelService := False
1526
+ end ;
1465
1527
end ;
1466
1528
end ;
1467
1529
@@ -1545,4 +1607,4 @@ begin
1545
1607
#endif
1546
1608
1547
1609
Exec(ExpandConstant(' {sys}\icacls.exe' ), ExpandConstant(' "{app}" /inheritancelevel:r ' ) + Permissions, ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode);
1548
- end ;
1610
+ end ;
0 commit comments