@oadank/dsh-input-tools 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/install-asr.ps1 +18 -8
- package/scripts/install-local-tts.ps1 +17 -7
package/package.json
CHANGED
package/scripts/install-asr.ps1
CHANGED
|
@@ -61,14 +61,20 @@ New-Item -ItemType Directory -Force -Path "$InstallDir\tmp" | Out-Null
|
|
|
61
61
|
# ---- 1b. 下载/解压工具函数(2026-08-21 增强:断点续传 + 完整性校验 + 损坏自动重试)----
|
|
62
62
|
# 之前 XDN 实测:GitHub 大文件下载中断 → 只下了 42.7MB/230MB → tar 报 Truncated → 脚本抛错退出,
|
|
63
63
|
# 用户只看到"跑到最后报错"毫无提示。现在 curl -C - 断点续传 + 解压后校验,损坏文件自动删除重下。
|
|
64
|
+
# ⚠️ PowerShell 坑:$ErrorActionPreference=Stop 时 curl/tar 写 stderr(进度/警告)会抛 NativeCommandError
|
|
65
|
+
# 中断脚本(0.3.5 实测踩中)。因此所有原生命令用 cmd /c 包装 + 2>nul 吞 stderr + 临时放宽 EAP,
|
|
66
|
+
# 只依据 $LASTEXITCODE 判断成败。
|
|
64
67
|
function Download-Resume {
|
|
65
68
|
param([string]$Url, [string]$OutFile)
|
|
66
69
|
for ($attempt = 1; $attempt -le 3; $attempt++) {
|
|
67
70
|
Write-Host " 下载(第 $attempt 次尝试): $Url" -ForegroundColor Yellow
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
$prevEAP = $ErrorActionPreference
|
|
72
|
+
$ErrorActionPreference = "Continue"
|
|
73
|
+
cmd /c "curl.exe -sL -C - --retry 3 --retry-delay 2 --connect-timeout 20 -o `"$OutFile`" `"$Url`" 2>nul"
|
|
74
|
+
$code = $LASTEXITCODE
|
|
75
|
+
$ErrorActionPreference = $prevEAP
|
|
76
|
+
if ($code -eq 0) { return $true }
|
|
77
|
+
Write-Host " 下载中断(exit=$code),3 秒后重试..." -ForegroundColor Yellow
|
|
72
78
|
Start-Sleep -Seconds 3
|
|
73
79
|
}
|
|
74
80
|
return $false
|
|
@@ -77,10 +83,14 @@ function Expand-TarBz2 {
|
|
|
77
83
|
param([string]$Archive, [string]$Dest, [int]$Strip = 0)
|
|
78
84
|
$tmpDir = Join-Path $Dest ".extract-tmp"
|
|
79
85
|
New-Item -ItemType Directory -Force -Path $tmpDir | Out-Null
|
|
80
|
-
$
|
|
81
|
-
if ($Strip -gt 0) { $
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
$stripArgs = ""
|
|
87
|
+
if ($Strip -gt 0) { $stripArgs = "--strip-components=$Strip" }
|
|
88
|
+
$prevEAP = $ErrorActionPreference
|
|
89
|
+
$ErrorActionPreference = "Continue"
|
|
90
|
+
cmd /c "tar -xjf `"$Archive`" -C `"$tmpDir`" $stripArgs 2>nul"
|
|
91
|
+
$code = $LASTEXITCODE
|
|
92
|
+
$ErrorActionPreference = $prevEAP
|
|
93
|
+
if ($code -ne 0) {
|
|
84
94
|
Write-Host " 解压失败:压缩包损坏或不完整($Archive)" -ForegroundColor Red
|
|
85
95
|
Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue
|
|
86
96
|
Remove-Item -Force $Archive -ErrorAction SilentlyContinue
|
|
@@ -18,13 +18,19 @@ $ErrorActionPreference = "Stop"
|
|
|
18
18
|
$Version = "v1.13.6"
|
|
19
19
|
|
|
20
20
|
# ---- 下载/解压工具函数(2026-08-21 增强:断点续传 + 完整性校验 + 损坏自动重试)----
|
|
21
|
+
# ⚠️ PowerShell 坑:$ErrorActionPreference=Stop 时 curl/tar 写 stderr 会抛 NativeCommandError(0.3.5 实测踩中)。
|
|
22
|
+
# 原生命令一律 cmd /c 包装 + 2>nul + 临时放宽 EAP,只依据 $LASTEXITCODE。
|
|
21
23
|
function Download-Resume {
|
|
22
24
|
param([string]$Url, [string]$OutFile)
|
|
23
25
|
for ($attempt = 1; $attempt -le 3; $attempt++) {
|
|
24
26
|
Write-Host " 下载(第 $attempt 次尝试): $Url" -ForegroundColor Yellow
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
$prevEAP = $ErrorActionPreference
|
|
28
|
+
$ErrorActionPreference = "Continue"
|
|
29
|
+
cmd /c "curl.exe -sL -C - --retry 3 --retry-delay 2 --connect-timeout 20 -o `"$OutFile`" `"$Url`" 2>nul"
|
|
30
|
+
$code = $LASTEXITCODE
|
|
31
|
+
$ErrorActionPreference = $prevEAP
|
|
32
|
+
if ($code -eq 0) { return $true }
|
|
33
|
+
Write-Host " 下载中断(exit=$code),3 秒后重试..." -ForegroundColor Yellow
|
|
28
34
|
Start-Sleep -Seconds 3
|
|
29
35
|
}
|
|
30
36
|
return $false
|
|
@@ -33,10 +39,14 @@ function Expand-TarBz2 {
|
|
|
33
39
|
param([string]$Archive, [string]$Dest, [int]$Strip = 0)
|
|
34
40
|
$tmpDir = Join-Path $Dest ".extract-tmp"
|
|
35
41
|
New-Item -ItemType Directory -Force -Path $tmpDir | Out-Null
|
|
36
|
-
$
|
|
37
|
-
if ($Strip -gt 0) { $
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
$stripArgs = ""
|
|
43
|
+
if ($Strip -gt 0) { $stripArgs = "--strip-components=$Strip" }
|
|
44
|
+
$prevEAP = $ErrorActionPreference
|
|
45
|
+
$ErrorActionPreference = "Continue"
|
|
46
|
+
cmd /c "tar -xjf `"$Archive`" -C `"$tmpDir`" $stripArgs 2>nul"
|
|
47
|
+
$code = $LASTEXITCODE
|
|
48
|
+
$ErrorActionPreference = $prevEAP
|
|
49
|
+
if ($code -ne 0) {
|
|
40
50
|
Write-Host " 解压失败:压缩包损坏或不完整($Archive)" -ForegroundColor Red
|
|
41
51
|
Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue
|
|
42
52
|
Remove-Item -Force $Archive -ErrorAction SilentlyContinue
|