diff options
| author | Caroline Larimore <caroline@larimo.re> | 2025-11-27 14:34:10 -0800 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2025-11-27 14:34:10 -0800 |
| commit | 2cca2719b38d9e8a59c174f3f00d8143e0a5a556 (patch) | |
| tree | 6c55047d4cd55ddcac41f2080ebbb0eaed1f5a0e | |
| parent | b1e559ef3a9e68538d057f37779277f12abaae77 (diff) | |
feat: check client jar hash before re-downloading
| -rwxr-xr-x | mcsh.sh | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |