commit ff65dc9ac5429d02392038abad5d06f9d93caed6
parent ed7dcde909cf3d0284f9854619d8956fb5d81d5e
Author: egor-achkasov <eaachkasov@gmail.com>
Date: Fri, 13 Mar 2026 15:05:51 +0000
Change content size type to usize from u64
Diffstat:
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/bin/cli/main.rs b/src/bin/cli/main.rs
@@ -49,8 +49,8 @@ fn parse_args() -> Result<Config> {
struct SlotInfo {
name: String,
- downloaded: u64,
- total: Option<u64>,
+ downloaded: usize,
+ total: Option<usize>,
}
impl SlotInfo {
@@ -85,7 +85,7 @@ impl ProgressState {
self.id_to_slot.insert(id, slot);
}
- fn update_progress(&mut self, id: usize, downloaded: u64, total: Option<u64>) {
+ fn update_progress(&mut self, id: usize, downloaded: usize, total: Option<usize>) {
if let Some(&slot) = self.id_to_slot.get(&id) {
if let Some(Some(info)) = self.slots.get_mut(slot) {
info.downloaded = downloaded;
diff --git a/src/lib/event.rs b/src/lib/event.rs
@@ -4,7 +4,7 @@ pub enum Event {
TotalDownloads(usize),
DlStarted { id: usize, name: String },
- DlProgress { id: usize, downloaded: u64, total: Option<u64> },
+ DlProgress { id: usize, downloaded: usize, total: Option<usize> },
DlCompleted { id: usize },
DlFailed { id: usize, error: anyhow::Error },
}
diff --git a/src/lib/lib.rs b/src/lib/lib.rs
@@ -163,14 +163,14 @@ async fn download(
}
};
- let total = response.content_length();
- let mut downloaded: u64 = 0;
+ let total: Option<usize> = response.content_length().and_then(|l| l.try_into().ok());
+ let mut downloaded: usize = 0;
let mut file_bytes = Vec::new();
loop {
match response.chunk().await {
Ok(Some(chunk)) => {
- downloaded += chunk.len() as u64;
+ downloaded += chunk.len();
file_bytes.extend_from_slice(&chunk);
let _ = tx.send(Event::DlProgress { id, downloaded, total });
}