fix: print error on failed to read metadata

this should be very rare, so no need to display it or abort
This commit is contained in:
electria 2026-07-31 17:47:12 -07:00
commit 1f909904c2
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -194,11 +194,13 @@ impl State {
path.as_ref()
.file_name()
.map_or(Cow::Borrowed("[no file]"), OsStr::to_string_lossy),
path.as_ref()
.metadata()
.map_or(Cow::Borrowed("[no size]"), |m| Cow::Owned(
Size::from_bytes(m.size()).to_string()
)),
path.as_ref().metadata().map_or_else(
|e| {
eprintln!("failed to read metadata: {e}");
Cow::Borrowed("[no size]")
},
|m| Cow::Owned(Size::from_bytes(m.size()).to_string())
),
image.width(),
image.height(),
));