mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-24 21:40:48 +02:00
fix(upload) reduce amount of emitted tauri events
This commit is contained in:
@@ -70,16 +70,27 @@ async fn download<R: Runtime>(
|
|||||||
let mut file = BufWriter::new(File::create(file_path).await?);
|
let mut file = BufWriter::new(File::create(file_path).await?);
|
||||||
let mut stream = response.bytes_stream();
|
let mut stream = response.bytes_stream();
|
||||||
|
|
||||||
|
let mut i = 0;
|
||||||
|
let mut temp_progress = 0;
|
||||||
|
|
||||||
while let Some(chunk) = stream.try_next().await? {
|
while let Some(chunk) = stream.try_next().await? {
|
||||||
|
i = i + 1;
|
||||||
file.write_all(&chunk).await?;
|
file.write_all(&chunk).await?;
|
||||||
let _ = window.emit(
|
temp_progress = temp_progress + chunk.len();
|
||||||
"download://progress",
|
if i >= 10 {
|
||||||
ProgressPayload {
|
window
|
||||||
id,
|
.emit(
|
||||||
progress: chunk.len() as u64,
|
"download://progress",
|
||||||
total,
|
ProgressPayload {
|
||||||
},
|
id,
|
||||||
);
|
progress: temp_progress as u64,
|
||||||
|
total,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.unwrap(); // TODO: remove the unwrap again.
|
||||||
|
i = 0;
|
||||||
|
temp_progress = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
file.flush().await?;
|
file.flush().await?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user