optimize:replace size magic number -1 with SIZE_TRANSFORMED constant (#1542)

This commit is contained in:
LeonWang0735
2026-01-17 19:24:44 +08:00
committed by GitHub
parent 76fa86fdc5
commit 3012119b81
2 changed files with 9 additions and 6 deletions
+4 -1
View File
@@ -161,6 +161,8 @@ pin_project! {
}
impl HashReader {
/// Used for transformation layers (compression/encryption)
pub const SIZE_PRESERVE_LAYER: i64 = -1;
pub fn new(
mut inner: Box<dyn Reader>,
size: i64,
@@ -169,7 +171,8 @@ impl HashReader {
sha256hex: Option<String>,
diskable_md5: bool,
) -> std::io::Result<Self> {
if size >= 0
// Get the innermost HashReader
if size != Self::SIZE_PRESERVE_LAYER
&& let Some(existing_hash_reader) = inner.as_hash_reader_mut()
{
if existing_hash_reader.bytes_read() > 0 {