Skip to content

Commit 0796f14

Browse files
committed
fix(review): 周回顾直写补 kb 重建与事件广播;收件请求慢速超时
1 parent b8c7b76 commit 0796f14

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎app/src-tauri/src/commands_after.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ pub fn batch_weekly_resolve(
8585
if decisions.len() > 200 {
8686
return Err("单次批决议上限 200 条".to_string());
8787
}
88-
weekly_resolve_core(&state.db, &decisions).map_err(|e| e.to_string())
88+
let app = state.app.clone();
89+
let view = weekly_resolve_core(&state.db, &decisions).map_err(|e| e.to_string())?;
90+
// 直写路径跳过 update_note 事件面——补 notes 域广播(列表/检索侧刷新)
91+
if view.done + view.abandoned > 0 {
92+
crate::notify::emit_changed(&app, crate::notify::DataDomain::Notes);
93+
}
94+
Ok(view)
8995
}
9096

9197
pub(crate) fn weekly_resolve_core(
@@ -156,6 +162,9 @@ pub(crate) fn weekly_resolve_core(
156162
let mut stmt = conn.prepare("UPDATE notes SET content = ?1, updated_at = ?2 WHERE id = ?3")?;
157163
for (note_id, (_title, content)) in &contents {
158164
stmt.execute(params![content, now, note_id])?;
165+
// 派生索引同事务重建(kb 影子表——与 db_notes::update_note 同钩子;
166+
// 绕过高层 update_note 的直写路径必须在此补齐,防 kb 陈旧)
167+
crate::kb_index::soft_rebuild_note(conn, *note_id, content);
159168
crate::db_task_index::rebuild_note_tasks(conn, *note_id, content);
160169
}
161170
}

‎app/src-tauri/src/commands_web_inbox.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,14 @@ fn write_simple(stream: &mut TcpStream, status: &str, body: &str, cors: bool) {
169169
}
170170

171171
fn read_request(stream: &mut TcpStream) -> Option<(String, String, HashMap<String, String>, Vec<u8>)> {
172+
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20);
172173
let mut buf = Vec::new();
173174
let mut chunk = [0u8; 4096];
174175
let mut head_end: Option<usize> = None;
175176
loop {
177+
if std::time::Instant::now() > deadline {
178+
return None; // 慢速/悬挂请求有界放弃(防连接占用线程)
179+
}
176180
match stream.read(&mut chunk) {
177181
Ok(0) => break,
178182
Ok(n) => {

0 commit comments

Comments
 (0)