refactor: 优化 NBPF 模块 - 缓存导入/合并重复方法/减少I/O
- crypto.py: 8个_imp_*方法改为_ModuleCache类缓存导入 - crypto.py: outer/inner加解密合并为_layer_encrypt/decrypt - crypto.py: 提取公共摘要计算方法,拆分长方法 - compiler.py: 删除_obfuscate_code中未使用的死代码 - loader.py: 3次ZIP扫描合并为1次缓存读取 - format.py: 更新为使用_ModuleCache - 合计减少205行代码(1707→1502)
This commit is contained in:
@@ -79,14 +79,14 @@ class DataStore:
|
||||
Log.error("Core", f"插件 '{plugin_name}' 试图将数据存储到项目目录: {custom_path}")
|
||||
return False
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
# 创建符号链接或记录映射
|
||||
mapping_file = self._base_dir / "_custom_paths.json"
|
||||
mappings = {}
|
||||
if mapping_file.exists():
|
||||
try:
|
||||
mappings = json.loads(mapping_file.read_text())
|
||||
except (json.JSONDecodeError, OSError):
|
||||
pass
|
||||
mappings[plugin_name] = str(path)
|
||||
mapping_file.write_text(json.dumps(mappings, indent=2))
|
||||
with self._lock:
|
||||
mapping_file = self._base_dir / "_custom_paths.json"
|
||||
mappings = {}
|
||||
if mapping_file.exists():
|
||||
try:
|
||||
mappings = json.loads(mapping_file.read_text())
|
||||
except (json.JSONDecodeError, OSError):
|
||||
pass # 映射文件不存在或损坏是正常情况
|
||||
mappings[plugin_name] = str(path)
|
||||
mapping_file.write_text(json.dumps(mappings, indent=2))
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user