Skip to content
Snippets Groups Projects
Verified Commit 2418286a authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Improve installer size formatting

parent 0ed65d7d
No related branches found
No related tags found
No related merge requests found
...@@ -71,20 +71,20 @@ fn disk_paths(paths: &mut Vec<(String, u64)>) { ...@@ -71,20 +71,20 @@ fn disk_paths(paths: &mut Vec<(String, u64)>) {
} }
} }
const KB: u64 = 1024; const KIB: u64 = 1024;
const MB: u64 = 1024 * KB; const MIB: u64 = 1024 * KIB;
const GB: u64 = 1024 * MB; const GIB: u64 = 1024 * MIB;
const TB: u64 = 1024 * GB; const TIB: u64 = 1024 * GIB;
fn format_size(size: u64) -> String { fn format_size(size: u64) -> String {
if size >= TB { if size >= 4 * TIB {
format!("{} TB", size / TB) format!("{:.1} TiB", size as f64 / TIB as f64)
} else if size >= GB { } else if size >= GIB {
format!("{} GB", size / GB) format!("{:.1} GiB", size as f64 / GIB as f64)
} else if size >= MB { } else if size >= MIB {
format!("{} MB", size / MB) format!("{:.1} MiB", size as f64 / MIB as f64)
} else if size >= KB { } else if size >= KIB {
format!("{} KB", size / KB) format!("{:.1} KiB", size as f64 / KIB as f64)
} else { } else {
format!("{} B", size) format!("{} B", size)
} }
...@@ -271,7 +271,7 @@ fn main() { ...@@ -271,7 +271,7 @@ fn main() {
}; };
// Pad to 1MiB // Pad to 1MiB
while bootloader.len() < 1024 * 1024 { while bootloader.len() < MIB as usize {
bootloader.push(0); bootloader.push(0);
} }
...@@ -314,7 +314,7 @@ fn main() { ...@@ -314,7 +314,7 @@ fn main() {
files.sort(); files.sort();
files.dedup(); files.dedup();
let mut buf = vec![0; 4 * 1024 * 1024]; let mut buf = vec![0; 4 * MIB as usize];
for (i, name) in files.iter().enumerate() { for (i, name) in files.iter().enumerate() {
eprintln!("copy {} [{}/{}]", name, i, files.len()); eprintln!("copy {} [{}/{}]", name, i, files.len());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment