Skip to content

Commit 9e9db30

Browse files
committed
Refactor cleanup helpers, stabilize module exports, and remove boolean output
- Replace Cleanup-* helpers with Clear-* (approved verbs) - Remove backticks from Export-ModuleMember to eliminate stray output - Fix symlink diagnostics and stabilize dashboard behavior - Add Fix-InstallerFreeze and Test-InstallerEnvironment helpers - Update Watchdog-MonitorInstaller and CleanCodePath for deterministic output - Update manifest and module root to match new function names - Refresh GUI XAML and startup script - Rename and update tests to match new Clear-* helpers
1 parent 9b7ac58 commit 9e9db30

20 files changed

Lines changed: 451 additions & 226 deletions

GUI/Start-VSCodeUpdaterGUI.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,18 @@ function Start-VSCodeUpdaterGUI {
413413
})
414414

415415
$dgVersions.Add_SelectionChanged({
416-
if (-not $script:vm.GuiInitialized) { return }
417-
418416
$selected = $dgVersions.SelectedItem
419-
if ($selected) {
420-
Write-TerminalLine "Selected Version: $($selected.Version)" "LightBlue"
417+
if (-not $selected) { return }
418+
419+
if ($selected.IsValid) {
420+
$script:btnSwitch.Content = "Switch Version"
421421
}
422+
else {
423+
$script:btnSwitch.Content = "Delete Version"
424+
}
425+
426+
Write-TerminalLine "Selected Version: $($selected.Version)" "LightBlue"
427+
Write-Log "Selected Version: $($selected.Version)"
422428
})
423429

424430
$chkAutoScroll.Add_Checked({

GUI/VSCodeUpdaterGUI.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@
7777
HeadersVisibility="Column"
7878
GridLinesVisibility="All"
7979
SelectionMode="Single"
80-
SelectionUnit="FullRow">
80+
SelectionUnit="FullRow"
81+
EnableRowVirtualization="False"
82+
EnableColumnVirtualization="False">
8183
<DataGrid.Columns>
8284
<DataGridTextColumn Header="Version" Binding="{Binding Version}" Width="180"/>
8385
<DataGridTextColumn Header="Path" Binding="{Binding Path}" Width="*"/>

Private/CleanCodePath.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function CleanCodePath {
1818

1919
if (-not (Test-Path $Path)) {
2020
Write-Log "[CLEANUP] VS Code path not found — skipping."
21-
return 90
21+
return $null
2222
}
2323

2424
# Validate symlink target if applicable
@@ -69,5 +69,5 @@ function CleanCodePath {
6969
}
7070

7171
Write-Log "[CLEANUP] VS Code cleanup complete."
72-
return 0
72+
return $null
7373
}

Private/Cleanup-InnoSetupWorkers.ps1

Lines changed: 0 additions & 42 deletions
This file was deleted.

Private/Cleanup-SetupBootstrapper.ps1

Lines changed: 0 additions & 56 deletions
This file was deleted.

Private/Cleanup-VSCodeHelpers.ps1

Lines changed: 0 additions & 51 deletions
This file was deleted.

Private/Clear-InnoSetupWorkers.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#
2+
SPDX-License-Identifier: MIT
3+
Copyright (c) 2026 Leon McClatchey, Linktech Engineering LLC
4+
5+
Package: VSCode-Updater
6+
Author: Leon McClatchey
7+
Company: Linktech Engineering LLC
8+
Created: 2026-04-16
9+
Modified: 2026-04-16
10+
File: Private/Cleanup-InnoSetupWorkers.ps1
11+
Version: 1.0.0
12+
Description: Detects and terminates active Inno Setup worker and bootstrapper processes to prevent installer hangs.
13+
#>
14+
function Clear-InnoSetupWorkers {
15+
Write-Log "[CLEANUP] Checking for InnoSetup workers"
16+
17+
#
18+
# PHASE 1 — FAST SCAN (names only)
19+
# Avoids touching protected processes and eliminates stalls.
20+
#
21+
$workers = Get-Process -ErrorAction SilentlyContinue |
22+
Where-Object {
23+
$_.Name -match '^is-[A-Za-z0-9]+(\.tmp|\.tmp\.exe)?$'
24+
}
25+
26+
if ($workers) {
27+
Write-Log "[CLEANUP] Terminating InnoSetup worker PIDs (fast scan): $($workers.Id -join ', ')"
28+
$workers | Stop-Process -Force -ErrorAction SilentlyContinue
29+
return
30+
}
31+
32+
#
33+
# PHASE 2 — DEEP SCAN (only for candidate processes)
34+
# Only touch Path/CommandLine on processes that look like InnoSetup workers.
35+
#
36+
Write-Log "[CLEANUP] No InnoSetup workers found in fast scan — running deep scan"
37+
38+
$candidates = Get-Process -ErrorAction SilentlyContinue |
39+
Where-Object {
40+
$_.Name -match '^is-[A-Za-z0-9]+' -or
41+
$_.Name -match 'Setup' -or
42+
$_.Name -match 'CodeSetup' -or
43+
$_.Name -match 'VSCodeSetup'
44+
}
45+
46+
$workers = $candidates |
47+
Where-Object {
48+
($_.Path -and $_.Path -match 'is-[A-Za-z0-9]+\.tmp') -or
49+
($_.CommandLine -and $_.CommandLine -match 'is-[A-Za-z0-9]+\.tmp') -or
50+
($_.CommandLine -and $_.CommandLine -match 'CodeSetup') -or
51+
($_.CommandLine -and $_.CommandLine -match 'VSCodeSetup')
52+
}
53+
54+
if ($workers) {
55+
Write-Log "[CLEANUP] Terminating InnoSetup worker PIDs (deep scan): $($workers.Id -join ', ')"
56+
$workers | Stop-Process -Force -ErrorAction SilentlyContinue
57+
}
58+
else {
59+
Write-Log "[CLEANUP] No InnoSetup worker processes found"
60+
}
61+
Out-Null
62+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<#
2+
SPDX-License-Identifier: MIT
3+
Copyright (c) 2026 Leon McClatchey, Linktech Engineering LLC
4+
5+
Package: VSCode-Updater
6+
Author: Leon McClatchey
7+
Company: Linktech Engineering LLC
8+
Created: 2026-04-16
9+
Modified: 2026-05-07
10+
File: Private/Cleanup-SetupBootstrapper.ps1
11+
Version: 1.0.1
12+
Description: Terminates VS Code setup bootstrapper processes to ensure a clean update state.
13+
#>
14+
function Clear-SetupBootstrapper {
15+
Write-Log "[CLEANUP] Checking for Setup bootstrapper processes"
16+
17+
#
18+
# PHASE 1 — FAST DETECTION (names only)
19+
# This avoids touching protected processes and eliminates the 120‑second stall.
20+
#
21+
$setup = Get-Process -ErrorAction SilentlyContinue |
22+
Where-Object {
23+
$_.Name -match "CodeSetup" -or
24+
$_.Name -match "VSCodeSetup" -or
25+
$_.Name -match "CodeUpdate" -or
26+
$_.Name -match "VSCodeUpdate" -or
27+
$_.Name -match "^is-[A-Za-z0-9]+(\.tmp|\.tmp\.exe)?$" -or
28+
$_.Name -match "tmp$" -or
29+
$_.Name -match "tmp\.exe$"
30+
}
31+
32+
if ($setup) {
33+
Write-Log "[CLEANUP] Found bootstrapper processes (fast scan) — terminating"
34+
$setup | Stop-Process -Force
35+
return
36+
}
37+
38+
#
39+
# PHASE 2 — SLOW DETECTION (path + command line)
40+
# Only runs if Phase 1 found nothing. This avoids hitting protected processes every run.
41+
#
42+
Write-Log "[CLEANUP] No bootstrapper processes found in fast scan — running deep scan"
43+
44+
# Candidate processes based on name only
45+
$candidates = Get-Process -ErrorAction SilentlyContinue |
46+
Where-Object {
47+
$_.Name -match "setup" -or
48+
$_.Name -match "update" -or
49+
$_.Name -match "^is-[A-Za-z0-9]+"
50+
}
51+
52+
$setup = $candidates |
53+
Where-Object {
54+
($_.Path -and $_.Path -match "VSCodeSetup") -or
55+
($_.Path -and $_.Path -match "CodeSetup") -or
56+
($_.Path -and $_.Path -match "is-[A-Za-z0-9]+\.tmp") -or
57+
($_.CommandLine -and $_.CommandLine -match "VSCodeSetup") -or
58+
($_.CommandLine -and $_.CommandLine -match "CodeSetup") -or
59+
($_.CommandLine -and $_.CommandLine -match "is-[A-Za-z0-9]+\.tmp")
60+
}
61+
62+
if ($setup) {
63+
Write-Log "[CLEANUP] Found bootstrapper processes (deep scan) — terminating"
64+
$setup | Stop-Process -Force
65+
}
66+
else {
67+
Write-Log "[CLEANUP] No setup bootstrapper processes found"
68+
}
69+
Out-Null
70+
}

0 commit comments

Comments
 (0)