Add AOI upload search and resilient downloads

This commit is contained in:
2026-04-28 15:47:25 +08:00
parent 60527e935f
commit a4fd1cff8e
12 changed files with 970 additions and 121 deletions
+33 -1
View File
@@ -21,6 +21,29 @@ function Get-RunningProcess {
}
}
function Get-ListeningProcessId {
param([int]$Port)
try {
$connection = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction Stop |
Select-Object -First 1
if ($connection) {
return [int]$connection.OwningProcess
}
} catch {
}
$lines = netstat -ano -p tcp | Select-String "LISTENING"
foreach ($line in $lines) {
$parts = ($line.Line.Trim() -split "\s+")
if ($parts.Count -ge 5 -and $parts[1].EndsWith(":$Port")) {
return [int]$parts[4]
}
}
return 0
}
$projectRoot = Split-Path -Parent $PSCommandPath
$statePath = Join-Path $projectRoot ".s1dl\web-ui-state.json"
@@ -36,7 +59,16 @@ if ($process) {
Write-Info "Stopping UI process $($process.Id)"
Stop-Process -Id $process.Id -Force
} else {
Write-Info "Tracked process is not running."
$listenerProcessId = 0
if ($state.port) {
$listenerProcessId = Get-ListeningProcessId -Port ([int]$state.port)
}
if ($listenerProcessId -gt 0) {
Write-Info "Stopping listener process $listenerProcessId"
Stop-Process -Id $listenerProcessId -Force
} else {
Write-Info "Tracked process is not running."
}
}
Remove-Item -LiteralPath $statePath -Force