From 2bf6776931c4c8837aa4327facfe63ea1235dd4e Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Tue, 30 Jun 2026 17:24:00 +0200 Subject: [PATCH] simplify rebuilt message --- backend/main.py | 7 +++---- backend/note_index.py | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/main.py b/backend/main.py index 415c9ea..f9844eb 100644 --- a/backend/main.py +++ b/backend/main.py @@ -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() diff --git a/backend/note_index.py b/backend/note_index.py index ebcc780..dbce629 100644 --- a/backend/note_index.py +++ b/backend/note_index.py @@ -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,