feat: show sizes under a gigabyte in megabytes

Every size cell converted bytes to gigabytes and formatted the float in
place, so anything below a gigabyte rendered as 0.00 GB. Books and
tracks are almost always that small, which made the Size columns in
Readarr and Lidarr useless.

Replace convert_to_gb and convert_f64_to_gb with one format_size helper
that renders gigabytes at or above 1 GiB and megabytes below it, at the
precision each site already used. Every render site across the four
servarr trees now calls it, including the two movie and episode detail
strings built on the network side. Values at or above a gigabyte render
byte for byte as before.

Give the Readarr book statistics and book file fixtures and the Lidarr
album statistics fixture realistic sub-gigabyte sizes so the megabyte
path is pinned by the committed snapshots.
This commit is contained in:
Dark-Alex-17 committed 2026-09-18 21:44:22 -06:00
1 parent bdeaf6ae35
commit f2ee1e71f6
117 files changed
+241 -250

No files matched your search

+8 -6
View File
@@ -79,12 +79,14 @@ pub fn init_logging_config() -> log4rs::Config {
.unwrap()
}
pub fn convert_to_gb(bytes: i64) -> f64 {
bytes as f64 / 1024f64.powi(3)
}
pub fn convert_f64_to_gb(bytes: f64) -> f64 {
bytes / 1024f64.powi(3)
pub fn format_size(bytes: i64, precision: usize) -> String {
if bytes >= 1024i64.pow(3) {
let gb = bytes as f64 / 1024f64.powi(3);
format!("{gb:.precision$} GB")
} else {
let mb = bytes as f64 / 1024f64.powi(2);
format!("{mb:.precision$} MB")
}
}
pub fn convert_runtime(runtime: i64) -> (i64, i64) {