保证素材批次补丁失败时状态原子

在修改状态前预检所有成功绑定节点的裁剪路径,避免中途错误留下部分更新。
This commit is contained in:
2026-09-12 21:27:05 +08:00
parent 103fe6fcd6
commit 124d94de93
@@ -30,6 +30,13 @@ pub fn apply_batch_patch(
&batch,
processed_dimensions,
)?;
for decision in decisions {
if let BindingDecision::Ok { to_node, .. } = decision {
if !cut_paths.contains_key(to_node) {
return Err(format!("缺少节点 {} 的 cut 图片", to_node.as_str()));
}
}
}
let rework_counts = batch_nodes
.iter()
.map(|node| (node.id.clone(), node.rework_count))
@@ -40,7 +47,7 @@ pub fn apply_batch_patch(
BindingDecision::Ok { to_node, .. } => {
let path = cut_paths
.get(to_node)
.ok_or_else(|| format!("缺少节点 {} 的 cut 图片", to_node.as_str()))?;
.expect("cut path presence validated before patch");
state.bound.push(BoundNode {
node_id: to_node.clone(),
cut_image_path: path.clone(),