From 2cca2719b38d9e8a59c174f3f00d8143e0a5a556 Mon Sep 17 00:00:00 2001 From: Caroline Larimore Date: Thu, 27 Nov 2025 14:34:10 -0800 Subject: feat: check client jar hash before re-downloading --- mcsh.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mcsh.sh b/mcsh.sh index ed3092a..ad330dd 100755 --- a/mcsh.sh +++ b/mcsh.sh @@ -239,6 +239,7 @@ function update_version ( "asset_index": .assetIndex.url, "java_version": .javaVersion.majorVersion, "client_url": .downloads.client.url, + "client_hash": .downloads.client.sha1, "main_class": .mainClass, "logging_config": .logging.client.file.url } @@ -291,9 +292,13 @@ function update_version ( } export -f download_asset - #TODO: check hash version="$(<<<"$meta" jq -r '.version')" - if ! [[ -e "$VERSIONS_DIR/$version/client.jar" ]]; then + hash="" + if [[ -e "$VERSIONS_DIR/$version/client.jar" ]]; then + hash="$(sha1sum "$VERSIONS_DIR/$version/client.jar")" + hash="${hash%%[[:space:]]*}" + fi + if ! [[ "$hash" == "$(<<<"$meta" jq -r '.client_hash')" ]]; then printf 'downloading %s client jar...\n' "$version" >&2 <<<"$meta" jq -r '.client_url' | xargs curl --silent -o "$VERSIONS_DIR/$version/client.jar" fi -- cgit v1.2.3