From a7c40da6cf141789e18a6ad2dd76ecbd101d94ce Mon Sep 17 00:00:00 2001 From: Linghong Date: Mon, 14 Sep 2026 19:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8=E5=88=87?= =?UTF-8?q?=E5=88=86=E9=97=AE=E9=A2=98=E8=8A=82=E7=82=B9=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E4=B8=8E=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 problematic_nodes 纳入失败判定并保留恢复状态 清理完成或放弃流程产生的 processed 和 binding 临时文件 --- .../commands/separation/persistence.rs | 31 +++++++++++++++++-- .../src/view/ui-editor/useUiEditorPage.ts | 10 +++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs index 7a4e44507..ee383d9c1 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs @@ -265,11 +265,11 @@ pub fn inspect_separation_recovery( } pub fn finalize_separation(root: &Path, asset_id: &str) -> Result<(), String> { - remove_separation_state(root, asset_id) + remove_separation_recovery_files(root, asset_id) } pub fn discard_separation_recovery(root: &Path, asset_id: &str) -> Result<(), String> { - remove_separation_state(root, asset_id) + remove_separation_recovery_files(root, asset_id) } fn remove_separation_state(root: &Path, asset_id: &str) -> Result<(), String> { @@ -281,6 +281,33 @@ fn remove_separation_state(root: &Path, asset_id: &str) -> Result<(), String> { } } +fn remove_separation_recovery_files(root: &Path, asset_id: &str) -> Result<(), String> { + let sidecar = separation_sidecar_dir(root, asset_id)?; + remove_separation_state(root, asset_id)?; + let entries = match fs::read_dir(&sidecar) { + Ok(entries) => entries, + Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()), + Err(error) => return Err(format!("读取 separation 临时文件失败:{error}")), + }; + for entry in entries { + let entry = entry.map_err(|error| format!("读取 separation 临时文件失败:{error}"))?; + let name = entry.file_name(); + let name = name.to_string_lossy(); + if name.starts_with("processed-") || name.starts_with("binding-") { + let path = entry.path(); + if entry + .file_type() + .map_err(|error| format!("检查 separation 临时文件失败:{error}"))? + .is_file() + { + fs::remove_file(&path) + .map_err(|error| format!("删除 separation 临时文件失败:{error}"))?; + } + } + } + Ok(()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts b/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts index e2c690b06..6e7504963 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts +++ b/apps/ai-game-creator-shell/src/view/ui-editor/useUiEditorPage.ts @@ -1212,7 +1212,15 @@ export function useUiEditorSession( '自动切分素材结果已写入编辑器,但 State 保存失败;sidecar 已保留,可继续恢复。', ); } - if (backfillErrors.length > 0) { + if ( + backfillErrors.length > 0 || + completedResult.problematic_nodes.length > 0 + ) { + if (completedResult.problematic_nodes.length > 0) { + backfillErrors.push( + `${completedResult.problematic_nodes.length} 个节点达到返工上限,需要人工处理`, + ); + } const recovery = await invoke( 'inspect_separation_recovery', { projectPath, assetId: resourceId }, -- 2.52.0