Skip to content

Commit ea07e16

Browse files
committed
fix: always overwrite shared libraries during download and add --force support to sherpa-onnx
Libraries are architecture-specific (e.g. arm64 vs x64 dylibs), so skipping existing ones could leave stale binaries from a different arch. Also passes the --force flag through to sherpa-onnx downloads for parity with llama-server and whisper-cpp. Includes minor prettier formatting fixes.
1 parent 29441c6 commit ea07e16

File tree

6 files changed

+37
-29
lines changed

6 files changed

+37
-29
lines changed

scripts/download-llama-server.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,17 @@ async function downloadBinary(platformArch, config, release, isForce = false) {
139139
console.log(` ${platformArch}: Extracted to ${config.outputName}`);
140140

141141
// Copy shared libraries (dylib/dll/so files)
142+
// Always overwrite — libraries are architecture-specific (e.g. arm64 vs x64 dylibs)
142143
if (config.libPattern) {
143144
const libraries = findLibrariesInDir(extractDir, config.libPattern);
144145

145146
for (const libPath of libraries) {
146147
const libName = path.basename(libPath);
147148
const destPath = path.join(BIN_DIR, libName);
148149

149-
// Only copy if not already exists (libraries are shared across architectures on same OS)
150-
if (!fs.existsSync(destPath)) {
151-
fs.copyFileSync(libPath, destPath);
152-
setExecutable(destPath);
153-
console.log(` ${platformArch}: Copied library ${libName}`);
154-
}
150+
fs.copyFileSync(libPath, destPath);
151+
setExecutable(destPath);
152+
console.log(` ${platformArch}: Copied library ${libName}`);
155153
}
156154
}
157155
} else {

scripts/download-sherpa-onnx.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ function matchesPattern(filename, pattern) {
8888
return false;
8989
}
9090

91-
async function downloadBinary(platformArch, config) {
91+
async function downloadBinary(platformArch, config, isForce = false) {
9292
if (!config) {
9393
console.log(` ${platformArch}: Not supported`);
9494
return false;
9595
}
9696

9797
const outputPath = path.join(BIN_DIR, config.outputName);
9898

99-
if (fs.existsSync(outputPath)) {
100-
console.log(` ${platformArch}: Already exists, skipping`);
99+
if (fs.existsSync(outputPath) && !isForce) {
100+
console.log(` ${platformArch}: Already exists (use --force to re-download)`);
101101
return true;
102102
}
103103

@@ -141,11 +141,9 @@ async function downloadBinary(platformArch, config) {
141141
versionedLibs.set(baseName, libName);
142142
}
143143

144-
if (!fs.existsSync(destPath)) {
145-
fs.copyFileSync(libPath, destPath);
146-
setExecutable(destPath);
147-
console.log(` ${platformArch}: Copied library ${libName}`);
148-
}
144+
fs.copyFileSync(libPath, destPath);
145+
setExecutable(destPath);
146+
console.log(` ${platformArch}: Copied library ${libName}`);
149147
}
150148

151149
// Replace unversioned copies with symlinks to versioned ones (macOS/Linux only)
@@ -192,7 +190,7 @@ async function main() {
192190
}
193191

194192
console.log(`Downloading for target platform (${args.platformArch}):`);
195-
const ok = await downloadBinary(args.platformArch, BINARIES[args.platformArch]);
193+
const ok = await downloadBinary(args.platformArch, BINARIES[args.platformArch], args.isForce);
196194
if (!ok) {
197195
console.error(`Failed to download binaries for ${args.platformArch}`);
198196
process.exitCode = 1;
@@ -216,7 +214,7 @@ async function main() {
216214
} else {
217215
console.log("Downloading binaries for all platforms:");
218216
for (const platformArch of Object.keys(BINARIES)) {
219-
await downloadBinary(platformArch, BINARIES[platformArch]);
217+
await downloadBinary(platformArch, BINARIES[platformArch], args.isForce);
220218
}
221219
}
222220

src/components/UpgradePrompt.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ export default function UpgradePrompt({
3030
<p className="text-sm text-muted-foreground">
3131
{(isPastDue
3232
? t("upgradePrompt.pastDueDescription", { limit: limit.toLocaleString() })
33-
: t("upgradePrompt.limitDescription", { used: wordsUsed.toLocaleString(), limit: limit.toLocaleString() })
34-
).split("\n").map((line, i, arr) => (
35-
<span key={i}>{line}{i < arr.length - 1 && <br />}</span>
36-
))}
33+
: t("upgradePrompt.limitDescription", {
34+
used: wordsUsed.toLocaleString(),
35+
limit: limit.toLocaleString(),
36+
})
37+
)
38+
.split("\n")
39+
.map((line, i, arr) => (
40+
<span key={i}>
41+
{line}
42+
{i < arr.length - 1 && <br />}
43+
</span>
44+
))}
3745
</p>
3846
</div>
3947

@@ -77,7 +85,9 @@ export default function UpgradePrompt({
7785
/>
7886
</div>
7987

80-
<p className="text-xs text-muted-foreground/60 text-center">{t("upgradePrompt.rollingWeeklyLimit")}</p>
88+
<p className="text-xs text-muted-foreground/60 text-center">
89+
{t("upgradePrompt.rollingWeeklyLimit")}
90+
</p>
8191
</DialogContent>
8292
</Dialog>
8393
);

src/hooks/useModelDownload.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ export function useModelDownload({
123123
data.error || t("hooks.modelDownload.errors.unknown"),
124124
data.code
125125
);
126-
const title = data.code === "EXTRACTION_FAILED"
127-
? t("hooks.modelDownload.installationFailed.title")
128-
: t("hooks.modelDownload.downloadFailed.title");
126+
const title =
127+
data.code === "EXTRACTION_FAILED"
128+
? t("hooks.modelDownload.installationFailed.title")
129+
: t("hooks.modelDownload.downloadFailed.title");
129130
setDownloadError(msg);
130131
showAlertDialogRef.current({ title, description: msg });
131132
setIsInstalling(false);
@@ -211,9 +212,10 @@ export function useModelDownload({
211212
result?.error || t("hooks.modelDownload.errors.unknown"),
212213
result?.code
213214
);
214-
const title = result?.code === "EXTRACTION_FAILED"
215-
? t("hooks.modelDownload.installationFailed.title")
216-
: t("hooks.modelDownload.downloadFailed.title");
215+
const title =
216+
result?.code === "EXTRACTION_FAILED"
217+
? t("hooks.modelDownload.installationFailed.title")
218+
: t("hooks.modelDownload.downloadFailed.title");
217219
setDownloadError(msg);
218220
showAlertDialog({ title, description: msg });
219221
} else {

src/locales/it/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,4 +1241,4 @@
12411241
}
12421242
}
12431243
}
1244-
}
1244+
}

src/locales/pt/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,4 +1241,4 @@
12411241
"restore": "Restaurar",
12421242
"close": "Fechar"
12431243
}
1244-
}
1244+
}

0 commit comments

Comments
 (0)