File tree 1 file changed +19
-8
lines changed
1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -70,16 +70,27 @@ async fn download<R: Runtime>(
70
70
let mut file = BufWriter :: new ( File :: create ( file_path) . await ?) ;
71
71
let mut stream = response. bytes_stream ( ) ;
72
72
73
+ let mut i = 0 ;
74
+ let mut temp_progress = 0 ;
75
+
73
76
while let Some ( chunk) = stream. try_next ( ) . await ? {
77
+ i = i + 1 ;
74
78
file. write_all ( & chunk) . await ?;
75
- let _ = window. emit (
76
- "download://progress" ,
77
- ProgressPayload {
78
- id,
79
- progress : chunk. len ( ) as u64 ,
80
- total,
81
- } ,
82
- ) ;
79
+ temp_progress = temp_progress + chunk. len ( ) ;
80
+ if i >= 10 {
81
+ window
82
+ . emit (
83
+ "download://progress" ,
84
+ ProgressPayload {
85
+ id,
86
+ progress : temp_progress as u64 ,
87
+ total,
88
+ } ,
89
+ )
90
+ . unwrap ( ) ; // TODO: remove the unwrap again.
91
+ i = 0 ;
92
+ temp_progress = 0 ;
93
+ }
83
94
}
84
95
file. flush ( ) . await ?;
85
96
You can’t perform that action at this time.
0 commit comments