simplify rebuilt message

This commit is contained in:
Gamosoft 2026-06-30 17:24:00 +02:00
parent 7470ee0103
commit 2bf6776931
2 changed files with 7 additions and 5 deletions

View File

@ -1845,18 +1845,17 @@ app.include_router(pages_router)
# ============================================================================
# Pre-build the note index off the request path. Mid-warmup requests are safe
# (bulk_set is serialized and short-circuits on the fingerprint).
# Success is logged from inside bulk_set so we get a single line for both
# the initial build and any subsequent rebuilds triggered by external changes.
@app.on_event("startup")
def _warmup_note_index() -> None:
import threading
import time
def _build() -> None:
t0 = time.perf_counter()
try:
ensure_index_built(config['storage']['notes_dir'])
logger.info("Note index ready (%.2fs)", time.perf_counter() - t0)
except Exception as exc:
logger.warning("Note index build failed (will retry on first request): %s", exc)
logger.warning("Vault index rebuild failed (will retry on first request): %s", exc)
threading.Thread(target=_build, name="note-index-warmup", daemon=True).start()

View File

@ -195,10 +195,13 @@ class NoteIndex:
self._raw_fingerprint = new_fp
self._built = True
elapsed = time.perf_counter() - t0
self._stats["build_count"] += 1
self._stats["last_build_ms"] = (time.perf_counter() - t0) * 1000
self._stats["last_build_ms"] = elapsed * 1000
self._stats["last_built_at"] = datetime.now(tz=timezone.utc).isoformat()
logger.info("Vault index rebuilt in %.2fs (%d notes)", elapsed, len(notes_meta))
def update_note(
self,
record: NoteRecord,