feat: smaller qa points

This commit is contained in:
Calum H. (IMB11)
2026-07-27 18:09:46 +01:00
parent 5b5468020d
commit f1f306d7ea
12 changed files with 109 additions and 38 deletions
+17 -18
View File
@@ -224,12 +224,11 @@ fn normalize_svg_from_path(icon_path: &Path) -> crate::Result<Bytes> {
))
})?;
if metadata.len() > INSTANCE_ICON_MAX_SVG_SOURCE_BYTES {
return Err(crate::ErrorKind::InputError(format!(
"SVG instance icons cannot exceed {} bytes before normalization",
INSTANCE_ICON_MAX_SVG_SOURCE_BYTES
))
.into());
}
return Err(crate::ErrorKind::InputError(format!(
"SVG instance icons cannot exceed {INSTANCE_ICON_MAX_SVG_SOURCE_BYTES} bytes before normalization"
))
.into());
}
let bytes = std::fs::read(icon_path).map_err(|error| {
crate::ErrorKind::InputError(format!(
@@ -245,15 +244,16 @@ fn normalize_svg(
resources_dir: Option<&Path>,
) -> crate::Result<Bytes> {
if bytes.len() as u64 > INSTANCE_ICON_MAX_SVG_SOURCE_BYTES {
return Err(crate::ErrorKind::InputError(format!(
"SVG instance icons cannot exceed {} bytes before normalization",
INSTANCE_ICON_MAX_SVG_SOURCE_BYTES
))
.into());
}
return Err(crate::ErrorKind::InputError(format!(
"SVG instance icons cannot exceed {INSTANCE_ICON_MAX_SVG_SOURCE_BYTES} bytes before normalization"
))
.into());
}
let mut options = resvg::usvg::Options::default();
options.resources_dir = resources_dir.map(Path::to_path_buf);
let mut options = resvg::usvg::Options {
resources_dir: resources_dir.map(Path::to_path_buf),
..Default::default()
};
options.fontdb_mut().load_system_fonts();
let tree =
resvg::usvg::Tree::from_data(bytes, &options).map_err(|error| {
@@ -308,9 +308,8 @@ fn has_svg_extension(path: &Path) -> bool {
}
fn icon_too_large_error() -> crate::Error {
crate::ErrorKind::InputError(format!(
"Instance icons cannot exceed {} bytes",
INSTANCE_ICON_MAX_BYTES
))
crate::ErrorKind::InputError(format!(
"Instance icons cannot exceed {INSTANCE_ICON_MAX_BYTES} bytes"
))
.into()
}