From 39092a5b87938a0c942e5eec7d1c1dff09182ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20R=C3=B3=C5=BCa=C5=84ski?= Date: Wed, 21 Aug 2024 14:50:20 +0200 Subject: [PATCH] reduce unpacking prints spam --- src/reader_with_bytes.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/reader_with_bytes.rs b/src/reader_with_bytes.rs index cb7272f..153e923 100644 --- a/src/reader_with_bytes.rs +++ b/src/reader_with_bytes.rs @@ -1,11 +1,11 @@ use std::io::{self, Read}; -const MB: u64 = 1024 * 1024; +const MB: usize = 1024 * 1024; pub struct ReaderWithBytes { reader: R, - bytes_read: u64, - last_reported: u64, + bytes_read: usize, + last_reported: usize, } impl ReaderWithBytes { @@ -21,9 +21,9 @@ impl ReaderWithBytes { impl Read for ReaderWithBytes { fn read(&mut self, buf: &mut [u8]) -> io::Result { let bytes_read = self.reader.read(buf)?; - self.bytes_read += bytes_read as u64; + self.bytes_read += bytes_read; - if self.bytes_read / MB > self.last_reported / MB { + if self.bytes_read > self.last_reported + 1000 * MB { println!("Unpacking... {} MB extracted", self.bytes_read / MB); self.last_reported = self.bytes_read; }