mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-30 13:04:13 +00:00
increase download chunk to 1MB, add human readable bytes format presentation
This commit is contained in:
parent
cc1597bbb7
commit
c53846649c
@ -497,7 +497,7 @@ impl Page {
|
|||||||
cancellable.clone(),
|
cancellable.clone(),
|
||||||
Priority::DEFAULT,
|
Priority::DEFAULT,
|
||||||
(
|
(
|
||||||
0x400, // 1024 bytes per chunk
|
0x100000, // 1M bytes per chunk
|
||||||
None, // unlimited
|
None, // unlimited
|
||||||
0 // initial totals
|
0 // initial totals
|
||||||
),
|
),
|
||||||
@ -506,7 +506,10 @@ impl Page {
|
|||||||
{
|
{
|
||||||
let action = action.clone();
|
let action = action.clone();
|
||||||
move |_, total| action.update.activate(
|
move |_, total| action.update.activate(
|
||||||
&format!("Received {total} bytes...")
|
&format!(
|
||||||
|
"Received {}...",
|
||||||
|
format_bytes(total)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
// on complete
|
// on complete
|
||||||
@ -969,3 +972,16 @@ fn snap_history(navigation: Rc<Navigation>) {
|
|||||||
navigation.history.add(request, true)
|
navigation.history.add(request, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Format bytes to KB/MB/GB presentation
|
||||||
|
fn format_bytes(total: usize) -> String {
|
||||||
|
if total < 1024 {
|
||||||
|
format!("{} bytes", total)
|
||||||
|
} else if total < 1024 * 1024 {
|
||||||
|
format!("{:.2} KB", total as f64 / 1024.0)
|
||||||
|
} else if total < 1024 * 1024 * 1024 {
|
||||||
|
format!("{:.2} MB", total as f64 / (1024.0 * 1024.0))
|
||||||
|
} else {
|
||||||
|
format!("{:.2} GB", total as f64 / (1024.0 * 1024.0 * 1024.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user