修复自动切分问题节点恢复与临时文件清理 #357
+29
-2
@@ -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::*;
|
||||
|
||||
@@ -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<SeparationRecoveryDTO>(
|
||||
'inspect_separation_recovery',
|
||||
{ projectPath, assetId: resourceId },
|
||||
|
||||
Reference in New Issue
Block a user