diff --git a/core_lib/src/hdl/inbound.rs b/core_lib/src/hdl/inbound.rs index e65f00b..25bfa05 100644 --- a/core_lib/src/hdl/inbound.rs +++ b/core_lib/src/hdl/inbound.rs @@ -664,7 +664,7 @@ impl InboundRequest { self.update_state( |e| { if let Some(tmd) = e.transfer_metadata.as_mut() { - tmd.ack_bytes += chunk_size as i64; + tmd.ack_bytes += chunk_size as u64; } }, true, @@ -819,7 +819,7 @@ impl InboundRequest { if !introduction.file_metadata.is_empty() && introduction.text_metadata.is_empty() { trace!("process_introduction: handling file_metadata"); let mut files_name = Vec::with_capacity(introduction.file_metadata.len()); - let mut total_bytes = 0; + let mut total_bytes: u64 = 0; for file in &introduction.file_metadata { info!("File name: {}", file.name()); @@ -851,7 +851,7 @@ impl InboundRequest { total_size: file.size(), file: None, }; - total_bytes += info.total_size; + total_bytes += info.total_size as u64; self.state.transferred_files.insert(file.payload_id(), info); files_name.push(file.name().to_owned()); } diff --git a/core_lib/src/hdl/info.rs b/core_lib/src/hdl/info.rs index 8901af1..a5a3807 100644 --- a/core_lib/src/hdl/info.rs +++ b/core_lib/src/hdl/info.rs @@ -25,6 +25,6 @@ pub struct TransferMetadata { pub pin_code: Option, pub text_description: Option, pub text_payload: Option, - pub total_bytes: i64, - pub ack_bytes: i64, + pub total_bytes: u64, + pub ack_bytes: u64, } diff --git a/core_lib/src/hdl/mod.rs b/core_lib/src/hdl/mod.rs index 80cf3a2..d114016 100644 --- a/core_lib/src/hdl/mod.rs +++ b/core_lib/src/hdl/mod.rs @@ -62,7 +62,6 @@ pub struct InnerState { pub pin_code: Option, pub transfer_metadata: Option, pub transferred_files: HashMap, - pub bytes_to_send: u64, // Everything needed for encryption/decryption/verif pub cipher_commitment: Option, diff --git a/core_lib/src/hdl/outbound.rs b/core_lib/src/hdl/outbound.rs index d9826fd..ade0c47 100644 --- a/core_lib/src/hdl/outbound.rs +++ b/core_lib/src/hdl/outbound.rs @@ -695,7 +695,9 @@ impl OutboundRequest { self.update_state( |e| { - e.bytes_to_send = total_to_send; + if let Some(tmd) = e.transfer_metadata.as_mut() { + tmd.total_bytes = total_to_send; + } e.transferred_files = transferred_files; }, false, @@ -844,8 +846,12 @@ impl OutboundRequest { if let Some(mu) = e.transferred_files.get_mut(¤t) { mu.bytes_transferred += bytes_read as i64; } + + if let Some(tmd) = e.transfer_metadata.as_mut() { + tmd.ack_bytes += bytes_read as u64; + } }, - false, + true, ); // If we just sent the last bytes of the file, mark it as finished