Files
notify/scripts/download.ps1
T
chuan c07a2cda72 fix: 引导脚本改为后台下载,不阻塞钩子;新增 download.ps1
- 旧版在钩子里同步 curl,大文件在慢链路上会被钩子超时杀掉,留下半截+锁
- 改为经 ShellExecute 启动隐藏 PowerShell 后台下载(脱离钩子进程),钩子毫秒级返回
- download.ps1 用 curl 下载、原子改名、清锁;纯 ASCII 避免 PowerShell 5.1 按 GBK 误读
2026-06-22 18:47:37 +08:00

20 lines
687 B
PowerShell

param(
[Parameter(Mandatory = $true)][string]$Url,
[Parameter(Mandatory = $true)][string]$Out,
[Parameter(Mandatory = $true)][string]$Lock
)
# Download notify.exe with curl to a temp file, then atomic-rename on success.
# Always remove the lock dir at the end (success or failure).
$tmp = $Out + ".downloading"
try {
& curl.exe -fsSL $Url -o $tmp
if ((Test-Path -LiteralPath $tmp) -and ((Get-Item -LiteralPath $tmp).Length -gt 0)) {
Move-Item -LiteralPath $tmp -Destination $Out -Force
}
}
finally {
Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $Lock -Recurse -Force -ErrorAction SilentlyContinue
}