Files
notify/bin/notify.cmd
T
chuan 0de6fe4064 feat: AOT 单文件静态链接 + Release 引导脚本
- csproj 静态链接 Skia/HarfBuzz/ANGLE(CoreUtils.*.Static),AOT 产出真单文件
- 发布后清理 .dll/.lib/.pdb,只留 notify.exe
- bin/notify.cmd 与 notify.sh:首次运行从 Release 下载 notify.exe
  原子下载(临时文件+改名)+ mkdir 锁,并发不重复下载,带陈旧锁恢复
- 修复 cmd 引导脚本管道 stdin 丢失:避免调 exe 前向前 goto,改用 call 子程序
- hooks.json 指向 notify.cmd,超时放宽以容纳首次下载
- .gitignore 放行两个脚本但忽略 notify.exe;.gitattributes 固定脚本换行符
2026-06-22 17:35:57 +08:00

44 lines
1.4 KiB
Batchfile

@echo off
rem ============================================================
rem Download URL (notify.exe is fetched from here on first run) -- edit as needed
set "DOWNLOAD_URL=https://github.com/OWNER/REPO/releases/latest/download/notify.exe"
rem ============================================================
setlocal
set "EXE=%~dp0notify.exe"
set "LOCK=%~dp0notify.download.lock"
rem only bootstrap on first run; the common path runs the exe directly (keeps piped stdin intact)
if not exist "%EXE%" call :bootstrap
if exist "%EXE%" "%EXE%" %*
endlocal
exit /b
:bootstrap
set "TMP=%~dp0notify.exe.%RANDOM%.tmp"
rem mkdir is atomic; success = this process downloads, failure = someone else is downloading
mkdir "%LOCK%" 2>nul
if errorlevel 1 goto :waitdl
rem double-check in case it just finished
if exist "%EXE%" ( rmdir "%LOCK%" 2>nul & exit /b )
rem download to temp then atomic rename, so no half-written exe is ever seen
curl -fsSL "%DOWNLOAD_URL%" -o "%TMP%"
if errorlevel 1 ( del "%TMP%" 2>nul & rmdir "%LOCK%" 2>nul & exit /b )
move /y "%TMP%" "%EXE%" >nul
rmdir "%LOCK%" 2>nul
exit /b
:waitdl
rem did not get the lock; wait for the exe to appear (up to ~60s)
set /a _w=0
:waitloop
if exist "%EXE%" exit /b
if %_w% geq 120 (
rem timed out; a killed download may have left a stale lock, clear it for next time
rmdir "%LOCK%" 2>nul
exit /b
)
ping -n 2 127.0.0.1 >nul
set /a _w+=1
goto :waitloop