refactor: apply zero-unwrap policy and optimize locks in store.rs and handlers
This commit is contained in:
1 parent
9f24e66d88
commit
8afbf97b11
33 files changed
+3127
-3207
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import re
|
||||
|
||||
with open("server/src/handlers.rs", "r", encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
|
||||
pattern = r'"(list_milestones|list_pinned_files|read_handoff_memos)" => \{\s*let req = parse_tool!\(args, id, ([a-zA-Z]+)\);\s*let mut [a-zA-Z_]+ = self\.state\.([a-zA-Z_]+)\.read\(\);\s*if let Some\(ns\) = req\.namespace \{\s*[a-zA-Z_]+\.retain\(\|.\| \w+\.namespace == ns\);\s*\}\s*let data = serde_json::to_string\(&[a-zA-Z_]+\)\.unwrap_or_default\(\);\s*Ok\(data\.to_string\(\)\)\s*\}'
|
||||
|
||||
def repl(m):
|
||||
return f'"{m.group(1)}" => handle_list_with_namespace!(self, {m.group(3)}, {m.group(2)}, args, id),'
|
||||
|
||||
new_text = re.sub(pattern, repl, text)
|
||||
|
||||
with open("server/src/handlers.rs", "w", encoding="utf-8") as f:
|
||||
f.write(new_text)
|
||||
Reference in new issue
Block a user