Skip to content

Commit

Permalink
feat: add outbound progress (#69)
Browse files Browse the repository at this point in the history
Signed-off-by: Martichou <[email protected]>
  • Loading branch information
Martichou authored May 1, 2024
1 parent 13236db commit 4db4383
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions core_lib/src/hdl/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions core_lib/src/hdl/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ pub struct TransferMetadata {
pub pin_code: Option<String>,
pub text_description: Option<String>,
pub text_payload: Option<String>,
pub total_bytes: i64,
pub ack_bytes: i64,
pub total_bytes: u64,
pub ack_bytes: u64,
}
1 change: 0 additions & 1 deletion core_lib/src/hdl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub struct InnerState {
pub pin_code: Option<String>,
pub transfer_metadata: Option<TransferMetadata>,
pub transferred_files: HashMap<i64, InternalFileInfo>,
pub bytes_to_send: u64,

// Everything needed for encryption/decryption/verif
pub cipher_commitment: Option<CipherCommitment>,
Expand Down
10 changes: 8 additions & 2 deletions core_lib/src/hdl/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -844,8 +846,12 @@ impl OutboundRequest {
if let Some(mu) = e.transferred_files.get_mut(&current) {
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
Expand Down

0 comments on commit 4db4383

Please sign in to comment.