전체 설치 스크립트 GitHub 릴리스 에셋 검증 및 폴백 다운로드 방어 로직 적용
This commit is contained in:
1 parent
5a67e7bbcf
commit
b41d2f68f3
21 files changed
+541
-190
No files matched your search
+15
-4
@@ -57,8 +57,10 @@ if ($arch -eq "AMD64") {
|
||||
$tag = $null
|
||||
try {
|
||||
Info "Fetching latest release tag from GitHub API..."
|
||||
$response = Invoke-RestMethod -Uri $API_URL -TimeoutSec 10
|
||||
$tag = $response.tag_name
|
||||
$response = Invoke-RestMethod -Uri $API_URL -Headers @{ 'User-Agent' = 'install-ocr-ps1' } -TimeoutSec 10
|
||||
if ($response -and $response.assets -and $response.assets.Count -gt 0) {
|
||||
$tag = $response.tag_name
|
||||
}
|
||||
} catch {
|
||||
Warn "Failed to retrieve the latest version from GitHub API. Using fallback version: $FALLBACK_VERSION"
|
||||
$tag = $FALLBACK_VERSION
|
||||
@@ -69,6 +71,7 @@ if (-not $tag) {
|
||||
}
|
||||
|
||||
$downloadUrl = "https://github.com/$REPO/releases/download/$tag/$assetName"
|
||||
$fallbackUrl = "https://github.com/$REPO/releases/download/$FALLBACK_VERSION/$assetName"
|
||||
Info "Resolved download URL: $downloadUrl"
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
@@ -85,8 +88,16 @@ $destFile = Join-Path $INSTALL_DIR "ocr.exe"
|
||||
|
||||
try {
|
||||
Info "Downloading binary..."
|
||||
# Invoke-WebRequest를 사용해 다운로드 진행
|
||||
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempFile -UseBasicParsing
|
||||
try {
|
||||
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempFile -UseBasicParsing
|
||||
} catch {
|
||||
if ($downloadUrl -ne $fallbackUrl) {
|
||||
Warn "Primary download failed. Retrying with fallback version ($FALLBACK_VERSION): $fallbackUrl"
|
||||
Invoke-WebRequest -Uri $fallbackUrl -OutFile $tempFile -UseBasicParsing
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
|
||||
# 다운로드 완료 후 복사
|
||||
if (Test-Path $destFile) {
|
||||
|
||||
Reference in new issue
Block a user