Skip to content

Commit 6efe783

Browse files
committed
feat: skip llama-server upgrade when local version matches remote
Parse the build number from `llama-server --version` output and compare with the remote release tag. If they match, skip the download entirely. Shows clear upgrade path info (e.g. "b8200 → b8287") when upgrading. Made-with: Cursor
1 parent bc6363d commit 6efe783

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

scripts/install.ps1

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function Install-CsghubLite {
139139
function Install-LlamaServer {
140140
$existingLlama = Get-Command "llama-server.exe" -ErrorAction SilentlyContinue
141141
if ($existingLlama) {
142-
Info "llama-server found at $($existingLlama.Source), upgrading to latest version..."
142+
Info "llama-server found at $($existingLlama.Source)"
143143
} else {
144144
Warn "llama-server not found. It is required for model inference."
145145
}
@@ -168,6 +168,31 @@ function Install-LlamaServer {
168168
}
169169

170170
$llamaTag = $release.tag_name
171+
172+
# Compare local and remote versions to skip unnecessary downloads.
173+
# llama-server --version outputs: "version: <build_number> (<hash>)"
174+
# Release tags use format: "b<build_number>"
175+
if ($existingLlama) {
176+
$localBuild = $null
177+
try {
178+
$verOutput = & $existingLlama.Source --version 2>&1 | Out-String
179+
if ($verOutput -match 'version:\s+(\d+)') {
180+
$localBuild = $Matches[1]
181+
}
182+
} catch {}
183+
184+
$remoteBuild = $llamaTag.TrimStart('b')
185+
if ($localBuild -and $localBuild -eq $remoteBuild) {
186+
Info "llama-server is already up to date ($llamaTag)."
187+
return
188+
}
189+
if ($localBuild) {
190+
Info "Upgrading llama-server from b$localBuild to $llamaTag..."
191+
} else {
192+
Info "Upgrading llama-server to $llamaTag..."
193+
}
194+
}
195+
171196
Info "llama.cpp release: $llamaTag"
172197

173198
$arch = $env:PROCESSOR_ARCHITECTURE

scripts/install.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ get_latest_version() {
141141
install_llama_server() {
142142
_existing_llama="$(command -v llama-server 2>/dev/null || true)"
143143
if [ -n "$_existing_llama" ]; then
144-
info "llama-server found at ${_existing_llama}, upgrading to latest version..."
144+
info "llama-server found at ${_existing_llama}"
145145
else
146146
warn "llama-server not found. It is required for model inference."
147147
fi
@@ -164,7 +164,6 @@ install_llama_server() {
164164

165165
OS="$(detect_os)"
166166
ARCH="$(detect_arch)"
167-
info "Downloading llama.cpp for ${OS}/${ARCH}..."
168167

169168
_gh_url="${GITHUB_API}/${LLAMA_CPP_REPO}/releases/latest"
170169
_gl_url="${GITLAB_API}/${GITLAB_LLAMA_ID}/releases/permalink/latest"
@@ -181,6 +180,25 @@ install_llama_server() {
181180
return
182181
fi
183182

183+
# Compare local and remote versions to skip unnecessary downloads.
184+
# llama-server --version outputs: "version: <build_number> (<hash>)"
185+
# Release tags use format: "b<build_number>"
186+
if [ -n "$_existing_llama" ]; then
187+
_local_build="$("$_existing_llama" --version 2>&1 | sed -n 's/.*version: *\([0-9]*\).*/\1/p' | head -1)"
188+
_remote_build="${_llama_tag#b}"
189+
if [ -n "$_local_build" ] && [ "$_local_build" = "$_remote_build" ]; then
190+
info "llama-server is already up to date (${_llama_tag})."
191+
return
192+
fi
193+
if [ -n "$_local_build" ]; then
194+
info "Upgrading llama-server from b${_local_build} to ${_llama_tag}..."
195+
else
196+
info "Upgrading llama-server to ${_llama_tag}..."
197+
fi
198+
fi
199+
200+
info "Downloading llama.cpp for ${OS}/${ARCH}..."
201+
184202
# Build ordered list of candidate asset names (best match first)
185203
_candidates=""
186204
case "$OS" in

0 commit comments

Comments
 (0)