cast usize for filesizeformat

This commit is contained in:
yggverse 2025-09-07 18:07:57 +03:00
parent f95c9526f2
commit 671ef0854a

View file

@ -33,7 +33,7 @@ fn index(
indexed: String, indexed: String,
magnet: String, magnet: String,
scrape: Option<Scrape>, scrape: Option<Scrape>,
size: u64, size: usize,
torrent: Torrent, torrent: Torrent,
} }
let (total, torrents) = public let (total, torrents) = public
@ -83,7 +83,7 @@ fn index(
indexed: torrent.time.format(&meta.format_time).to_string(), indexed: torrent.time.format(&meta.format_time).to_string(),
magnet: torrent.magnet(meta.trackers.as_ref()), magnet: torrent.magnet(meta.trackers.as_ref()),
scrape: scraper.scrape(&torrent.info_hash), scrape: scraper.scrape(&torrent.info_hash),
size: torrent.size, size: torrent.size as usize, // required by `filesizeformat` impl
torrent torrent
}), }),
Err(e) => { Err(e) => {
@ -114,7 +114,7 @@ fn info(
struct F { struct F {
href: Option<String>, href: Option<String>,
path: String, path: String,
size: u64, size: usize,
} }
let torrent = Torrent::from_public(&t.bytes, t.time).map_err(|e| { let torrent = Torrent::from_public(&t.bytes, t.time).map_err(|e| {
error!("Torrent parse error: `{e}`"); error!("Torrent parse error: `{e}`");
@ -142,7 +142,7 @@ fn info(
F { F {
href: public.href(&torrent.info_hash, &p), href: public.href(&torrent.info_hash, &p),
path: p, path: p,
size: f.length, size: f.length as usize, // required by `filesizeformat` impl
} }
}) })
.collect::<Vec<F>>() .collect::<Vec<F>>()
@ -150,7 +150,7 @@ fn info(
indexed: torrent.time.format(&meta.format_time).to_string(), indexed: torrent.time.format(&meta.format_time).to_string(),
magnet: torrent.magnet(meta.trackers.as_ref()), magnet: torrent.magnet(meta.trackers.as_ref()),
scrape: scraper.scrape(&torrent.info_hash), scrape: scraper.scrape(&torrent.info_hash),
size: torrent.size, size: torrent.size as usize, // required by `filesizeformat` impl
torrent torrent
}, },
)) ))