fix(sync): embed triggers async with DEVNULL output; memory rebuild runs once in commands layer; PDF errors are expected for missing Zotero files

This commit is contained in:
Research Assistant 2026-05-18 22:13:38 +08:00
parent 3c770aeee4
commit 5902f6cd4b
2 changed files with 12 additions and 27 deletions

View file

@ -66,27 +66,20 @@ def run(args: argparse.Namespace) -> int:
if json_output:
print(result.to_json())
if result.ok and not dry_run:
try:
from paperforge.memory.builder import build_from_index
build_from_index(vault)
except Exception:
pass
try:
import subprocess, sys
subprocess.Popen(
[sys.executable, "-m", "paperforge", "embed", "build", "--resume"],
cwd=str(vault),
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if sys.platform == "win32" else 0,
)
except Exception:
pass
if result.ok and not dry_run and not index_only and not selection_only:
import subprocess, sys
subprocess.Popen(
[sys.executable, "-m", "paperforge", "embed", "build", "--resume"],
cwd=str(vault),
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if sys.platform == "win32" else 0,
)
return 0
if not result.ok:
return 1
# best-effort: rebuild memory DB for immediate search
# best-effort: memory rebuild
try:
from paperforge.memory.builder import build_from_index
counts = build_from_index(vault)
@ -94,15 +87,16 @@ def run(args: argparse.Namespace) -> int:
except Exception as e:
print(f"memory: deferred ({e})")
# best-effort: trigger vector resume in background
# trigger vector resume (background, no output)
try:
import subprocess, sys
subprocess.Popen(
[sys.executable, "-m", "paperforge", "embed", "build", "--resume"],
cwd=str(vault),
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if sys.platform == "win32" else 0,
)
print("vector: resume started in background")
print("vector: resume started")
except Exception as e:
print(f"vector: deferred ({e})")

View file

@ -282,15 +282,6 @@ class SyncService:
if orphaned > 0 or flat_cleaned > 0:
index_count = asset_index.build_index(self.vault, verbose)
# ├─ best-effort: rebuild memory DB (does not affect sync result)
try:
from paperforge.memory.builder import build_from_index
from paperforge.memory.db import get_memory_db_path
if get_memory_db_path(self.vault).exists():
build_from_index(self.vault)
except Exception as exc:
logger.warning("memory rebuild deferred: %s", exc)
# ── Phase 4: Prune orphans ──
prune_result = None
if prune or prune_force: