mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-15 07:12:52 +00:00
doc_optimize: reject a target_bytes too large for usize
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ef81dd1277
commit
86af84171f
1 file changed
+1
-1
@@ -1308,7 +1308,7 @@ impl Automation {
|
||||
};
|
||||
let target = match a.opt_int("target_bytes")? {
|
||||
None => None,
|
||||
Some(t) if t >= 1 => Some(t as usize),
|
||||
Some(t) if t >= 1 => Some(usize::try_from(t).map_err(|_| ToolError::InvalidArgs(format!("target_bytes {t} is too large")))?),
|
||||
Some(t) => return Err(ToolError::InvalidArgs(format!("target_bytes must be at least 1, not {t}"))),
|
||||
};
|
||||
let (mut bytes, mut r) = self.session.optimized_bytes(id, &settings, &discard).map_err(failed)?;
|
||||
|
||||
Reference in new issue
Block a user