mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
only warn if CRC appears to be missing (#12722)
an alternative to #12706 fixes #12694
This commit is contained in:
parent
2f297b179d
commit
c0ed5693a7
4 changed files with 26 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5348,6 +5348,7 @@ dependencies = [
|
|||
"thiserror 2.0.12",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"uv-distribution-filename",
|
||||
"uv-normalize",
|
||||
"uv-pypi-types",
|
||||
|
|
|
@ -92,11 +92,21 @@ pub async fn unzip<R: tokio::io::AsyncRead + Unpin>(
|
|||
let computed = reader.compute_hash();
|
||||
let expected = reader.entry().crc32();
|
||||
if computed != expected {
|
||||
return Err(Error::BadCrc32 {
|
||||
let error = Error::BadCrc32 {
|
||||
path: relpath,
|
||||
computed,
|
||||
expected,
|
||||
});
|
||||
};
|
||||
// There are some cases where we fail to get a proper CRC.
|
||||
// This is probably connected to out-of-line data descriptors
|
||||
// which are problematic to access in a streaming context.
|
||||
// In those cases the CRC seems to reliably be stubbed inline as 0,
|
||||
// so we downgrade this to a (hidden-by-default) warning.
|
||||
if expected == 0 {
|
||||
warn!("presumed missing CRC: {error}");
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ futures = { workspace = true }
|
|||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio-util = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
zip = { workspace = true }
|
||||
|
||||
[lints]
|
||||
|
|
|
@ -258,11 +258,21 @@ pub async fn read_metadata_async_stream<R: futures::AsyncRead + Unpin>(
|
|||
let computed = reader.compute_hash();
|
||||
let expected = reader.entry().crc32();
|
||||
if computed != expected {
|
||||
return Err(Error::BadCrc32 {
|
||||
let error = Error::BadCrc32 {
|
||||
path,
|
||||
computed,
|
||||
expected,
|
||||
});
|
||||
};
|
||||
// There are some cases where we fail to get a proper CRC.
|
||||
// This is probably connected to out-of-line data descriptors
|
||||
// which are problematic to access in a streaming context.
|
||||
// In those cases the CRC seems to reliably be stubbed inline as 0,
|
||||
// so we downgrade this to a (hidden-by-default) warning.
|
||||
if expected == 0 {
|
||||
tracing::warn!("presumed missing CRC: {error}");
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
}
|
||||
|
||||
let metadata = ResolutionMetadata::parse_metadata(&contents)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue