Fix SHA-256 verification mismatch when downloading language servers (#35953)

Closes #35642 

Release Notes:

- Fixed: when the expected digest included a "sha256:" prefix while the
computed
digest has no prefix.
This commit is contained in:
jingyuexing 2025-08-11 03:40:14 +08:00 committed by GitHub
parent 6bd2f8758e
commit 72761797a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,6 +62,12 @@ pub(crate) async fn download_server_binary(
format!("saving archive contents into the temporary file for {url}",)
})?;
let asset_sha_256 = format!("{:x}", writer.hasher.finalize());
// Strip "sha256:" prefix for comparison
let expected_sha_256 = expected_sha_256
.strip_prefix("sha256:")
.unwrap_or(expected_sha_256);
anyhow::ensure!(
asset_sha_256 == expected_sha_256,
"{url} asset got SHA-256 mismatch. Expected: {expected_sha_256}, Got: {asset_sha_256}",