diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index 7c5bf796..d036f00a 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -6,6 +6,7 @@ import { invoke, Channel } from '@tauri-apps/api/core' interface ProgressPayload { progress: number + progressTotal: number total: number transferSpeed: number } diff --git a/plugins/upload/src/lib.rs b/plugins/upload/src/lib.rs index 20b7d626..d8f5f43c 100644 --- a/plugins/upload/src/lib.rs +++ b/plugins/upload/src/lib.rs @@ -61,6 +61,7 @@ impl Serialize for Error { #[serde(rename_all = "camelCase")] struct ProgressPayload { progress: u64, + progress_total: u64, total: u64, transfer_speed: u64, } @@ -98,7 +99,8 @@ async fn download( file.write_all(&chunk).await?; stats.record_chunk_transfer(chunk.len()); let _ = on_progress.send(ProgressPayload { - progress: stats.total_transferred, + progress: chunk.len() as u64, + progress_total: stats.total_transferred, total, transfer_speed: stats.transfer_speed, }); @@ -153,6 +155,7 @@ fn file_to_body(channel: Channel, file: File) -> reqwest::Body stats.record_chunk_transfer(progress as usize); let _ = channel.send(ProgressPayload { progress, + progress_total: stats.total_transferred, total, transfer_speed: stats.transfer_speed, });