修复 DirectProject 首次历史写入
Project CI / Native shell tests (pull_request) Failing after 3m25s
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Frontend tests (pull_request) Failing after 1m47s

历史文件不存在时跳过幂等反向扫描

保留首条带 id item 的正常追加
This commit is contained in:
2026-09-05 10:56:04 +08:00
parent 1fdfe4624c
commit 61c33cd3c7
@@ -140,15 +140,18 @@ pub(crate) fn append_direct_project_history_item_at(
}
let _project_lock = crate::project::acquire_project_write_lock(root, "conversation.write")?;
let path = history_path(root);
prepare_game_creator_private_path_for_read(&path, false, "DirectProject 历史")?;
let history_exists =
prepare_game_creator_private_path_for_read(&path, false, "DirectProject 历史")?;
let lock = project_append_lock_for(&path)?;
let _append_guard = lock.lock("DirectProject 历史追加写")?;
if let Some(item_id) = item.get("id").and_then(Value::as_str) {
if let Some(existing) = find_direct_project_history_item_by_id_at(&path, item_id)? {
if &existing == item {
return Ok(());
if history_exists {
if let Some(item_id) = item.get("id").and_then(Value::as_str) {
if let Some(existing) = find_direct_project_history_item_by_id_at(&path, item_id)? {
if &existing == item {
return Ok(());
}
return Err(format!("DirectProject 历史 item id 冲突:{item_id}"));
}
return Err(format!("DirectProject 历史 item id 冲突:{item_id}"));
}
}
let line = record(item)?;