Files
mcp-memory/fix_search_commit.py
T

20 lines
583 B
Python

import re
with open("server/src/search.rs", "r", encoding="utf-8") as f:
content = f.read()
# Add pub fn commit
commit_code = """
pub fn commit(&self) -> tantivy::Result<()> {
let mut writer = self.writer.lock().unwrap();
writer.commit()?;
Ok(())
}
"""
content = content.replace(" pub fn search(", commit_code + "\n pub fn search(")
content = content.replace("let mut writer = self.writer.lock().unwrap();", "let writer = self.writer.lock().unwrap();")
with open("server/src/search.rs", "w", encoding="utf-8") as f:
f.write(content)