Skip to content

Commit e342c44

Browse files
committed
fix: detect already-current binary via SHA256 hash comparison
When the downloaded binary has the same SHA256 hash as the installed binary, the upgrade already succeeded (or the binary was already at the target release). Report this clearly instead of showing misleading before/after versions when upstream has a stale version string. Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
1 parent 1ceffb7 commit e342c44

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

scripts/installers/github_release_binary.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ fi
225225
# - Clean fallback if ~/.local/bin version is removed
226226
# - System packages can still satisfy dependencies for other tools
227227

228+
# Check if binary is already at target version by comparing SHA256 hashes
229+
# This catches cases where upstream version string is wrong (e.g., sd v1.1.0 reports 1.0.0)
230+
BINARY_ALREADY_CURRENT=""
231+
if [ -f "$BIN_DIR/$BINARY_NAME" ] && [ -f "$BINARY_PATH" ]; then
232+
OLD_HASH="$(sha256sum "$BIN_DIR/$BINARY_NAME" 2>/dev/null | awk '{print $1}')"
233+
NEW_HASH="$(sha256sum "$BINARY_PATH" 2>/dev/null | awk '{print $1}')"
234+
if [ -n "$OLD_HASH" ] && [ -n "$NEW_HASH" ] && [ "$OLD_HASH" = "$NEW_HASH" ]; then
235+
BINARY_ALREADY_CURRENT="true"
236+
fi
237+
fi
238+
228239
# Install
229240
if [ -n "$PRESERVE_DIR" ] && [ -n "$EXTRACT_DIR" ]; then
230241
# Tool requires full directory structure (e.g., GAM with bundled Python)
@@ -268,6 +279,9 @@ path="$(command -v "$BINARY_NAME" 2>/dev/null || true)"
268279
printf "[%s] before: %s\n" "$TOOL" "${before:-<none>}"
269280
printf "[%s] after: %s\n" "$TOOL" "${after:-<none>}"
270281
if [ -n "$path" ]; then printf "[%s] path: %s\n" "$TOOL" "$path"; fi
282+
if [ "$BINARY_ALREADY_CURRENT" = "true" ]; then
283+
printf "[%s] note: binary already matches target release %s (upstream version string may be stale)\n" "$TOOL" "$LATEST"
284+
fi
271285

272286
# Refresh snapshot after successful installation
273287
refresh_snapshot "$TOOL"

0 commit comments

Comments
 (0)