|
|
@@ -82,6 +82,7 @@ def _process_import(task_id: str, tmp_path: Path, import_type: str, source_name:
|
|
|
imported = []
|
|
|
skipped = []
|
|
|
errors = []
|
|
|
+ imported_files = [] # 记录导入的 docx 文件路径,用于备份
|
|
|
|
|
|
for i, q in enumerate(questions):
|
|
|
update_import_task(conn, task_id, completed=i + 1, message=f"处理第 {i + 1}/{total} 题...")
|
|
|
@@ -118,9 +119,7 @@ def _process_import(task_id: str, tmp_path: Path, import_type: str, source_name:
|
|
|
body = extract_plain_text(docx_path)
|
|
|
update_fts_body(conn2, pid, body)
|
|
|
imported.append({"num": q["question_num"], "id": pid, "type": info["question_type"]})
|
|
|
-
|
|
|
- # 标记需要备份的文件
|
|
|
- # (简化处理:操作后统一备份)
|
|
|
+ imported_files.append(str(docx_path))
|
|
|
finally:
|
|
|
conn2.close()
|
|
|
|
|
|
@@ -141,9 +140,9 @@ def _process_import(task_id: str, tmp_path: Path, import_type: str, source_name:
|
|
|
|
|
|
update_import_task(conn, task_id, status="done", message="导入完成", result=result)
|
|
|
|
|
|
- # 自动备份
|
|
|
+ # 自动备份(bank.db + 导入的 docx)
|
|
|
try:
|
|
|
- auto_backup(config)
|
|
|
+ auto_backup(config, changed_files=imported_files if imported_files else None)
|
|
|
except Exception:
|
|
|
pass
|
|
|
|