Skip to content

Commit 2ded4bc

Browse files
fix: serialise summary-cache fingerprint read-compare-write under a module lock (#158)
* fix: serialise summary-cache fingerprint read-compare-write under a module lock * fix: patch cache paths in concurrency tests and reuse nocache builders * refactor: extract shared get_or_build_cached and tidy concurrency tests * fix: share workspace_storage_fingerprint and guard cache writes
1 parent b2a4d0d commit 2ded4bc

9 files changed

Lines changed: 562 additions & 201 deletions

services/export_engine.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from models import Bubble
1414
from models.export import CollectedExportEntry
15-
from services.summary_cache import fingerprint_workspace_storage, nocache_enabled
15+
from services.summary_cache import nocache_enabled
1616
from services.workspace_context import (
1717
WorkspaceContext,
1818
enrich_workspace_context_from_global_db,
@@ -22,7 +22,6 @@
2222
from services.workspace_db import (
2323
COMPOSER_ROWS_WITH_HEADERS_SQL,
2424
collect_workspace_entries,
25-
global_storage_db_path,
2625
load_code_block_diff_map,
2726
open_global_db,
2827
safe_fetchall,
@@ -84,7 +83,6 @@ class WorkspaceOrchestration:
8483

8584
workspace_path: str
8685
workspace_entries: list[dict[str, Any]]
87-
fingerprint: dict[str, Any]
8886
ctx: WorkspaceContext
8987
workspace_id_to_display_name: dict[str, str]
9088
workspace_id_to_slug: dict[str, str]
@@ -135,21 +133,12 @@ def prepare_workspace_orchestration(
135133
nocache: bool = False,
136134
workspace_entries: list[dict[str, Any]] | None = None,
137135
) -> WorkspaceOrchestration:
138-
"""Scan workspace storage and resolve maps (with summary-cache fingerprint)."""
136+
"""Scan workspace storage and resolve maps for listing and export."""
139137
entries = (
140138
workspace_entries
141139
if workspace_entries is not None
142140
else collect_workspace_entries(workspace_path)
143141
)
144-
gdb = global_storage_db_path(workspace_path)
145-
cli_path = get_cli_chats_path()
146-
fingerprint = fingerprint_workspace_storage(
147-
workspace_path,
148-
entries,
149-
global_db_path=gdb if os.path.isfile(gdb) else None,
150-
rules=rules,
151-
cli_chats_path=cli_path if os.path.isdir(cli_path) else None,
152-
)
153142
ctx = resolve_workspace_context_cached(
154143
workspace_path,
155144
rules,
@@ -160,7 +149,6 @@ def prepare_workspace_orchestration(
160149
return WorkspaceOrchestration(
161150
workspace_path=workspace_path,
162151
workspace_entries=entries,
163-
fingerprint=fingerprint,
164152
ctx=ctx,
165153
workspace_id_to_display_name=display_name,
166154
workspace_id_to_slug=slug_map,

services/search_index.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
)
3030
from services.summary_cache import (
3131
CACHE_DIR,
32-
fingerprint_workspace_storage,
3332
nocache_enabled,
33+
workspace_storage_fingerprint,
3434
)
3535
from services.workspace_db import (
3636
COMPOSER_ROWS_WITH_HEADERS_SQL,
@@ -40,7 +40,6 @@
4040
)
4141
from utils.path_helpers import to_epoch_ms
4242
from utils.exclusion_rules import RuleTokens
43-
from utils.workspace_path import get_cli_chats_path
4443

4544
__all__ = [
4645
"SEARCH_INDEX_FILE",
@@ -130,15 +129,7 @@ def index_search_enabled() -> bool:
130129

131130
def _storage_fingerprint(workspace_path: str, rules: list[RuleTokens]) -> dict[str, Any]:
132131
entries = collect_workspace_entries(workspace_path)
133-
gdb = global_storage_db_path(workspace_path)
134-
cli_path = get_cli_chats_path()
135-
return fingerprint_workspace_storage(
136-
workspace_path,
137-
entries,
138-
global_db_path=gdb if os.path.isfile(gdb) else None,
139-
rules=rules,
140-
cli_chats_path=cli_path if os.path.isdir(cli_path) else None,
141-
)
132+
return workspace_storage_fingerprint(workspace_path, entries, rules)
142133

143134

144135
def _open_index_db(*, readonly: bool = True) -> sqlite3.Connection | None:

0 commit comments

Comments
 (0)