Stelle bestehende Quellzuordnungen wieder her und halte Connectoren beim eigenen Konto.
Deploy Development / deploy (push) Successful in 28s
Test Suite / pytest-backend (push) Failing after 2m11s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 10s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-19 16:58:50 +02:00
1 parent d6b70d8f92
commit c3a07cee64
8 files changed
+250 -9

No files matched your search

+4
View File
@@ -58,7 +58,11 @@ def _prepare_source_storage(settings: Settings) -> None:
from app.media.port import ensure_legacy_instance
from app.sourcebind import backfill_source_bindings
from app.sources import _install_sources
# The process that migrates has not imported the application yet.
# Without the modules, a legacy reference would stay unresolved.
_install_sources()
with psycopg.connect(settings.dsn(), row_factory=dict_row) as conn:
backfill_source_bindings(conn)
ensure_legacy_instance(conn, settings.media_root)
+11 -3
View File
@@ -218,12 +218,20 @@ def _element_body(conn, actor: UUID, element: dict) -> dict:
if revealed:
external["external_id"] = ref["external_id"]
payload["external"] = external
from app.sourcebind import resolve_for_read
from app.sourceregistry import get_source
if resolution in {"ambiguous", "unresolved"} and get_source(ref["source"]) is not None:
payload["preview"] = {"available": False, "media": "unassigned", "source": ref["source"]}
else:
module = get_source(ref["source"])
if module is None:
payload["preview"] = _preview_meta("external_ref", None, ref["source"])
else:
resolved = resolve_for_read(conn, element["owner_subject_id"], ref["source"], ref, None)
if resolved.code == "ok":
payload["preview"] = _preview_meta("external_ref", None, ref["source"])
elif actor == element["owner_subject_id"]:
payload["preview"] = {"available": False, "media": "unassigned", "source": ref["source"]}
else:
payload["preview"] = {"available": False, "media": "none", "source": ref["source"]}
return payload
+10 -2
View File
@@ -146,7 +146,15 @@ def attach_new_reference(conn, element_id: UUID) -> None:
def backfill_source_bindings(conn) -> None:
"""Idempotent. Bound and ambiguous rows stay. Unique unresolved stock is bound once."""
"""Idempotent. Unique stock is bound once. A stored id is never retargeted.
Startup calls this before the application has imported the connector
modules. Register them first, otherwise every existing reference stays
unresolved and the case or matter can no longer open its originals.
"""
from app.sources import _install_sources
_install_sources()
conn.execute(
"""
UPDATE external_references
@@ -160,7 +168,7 @@ def backfill_source_bindings(conn) -> None:
FROM external_references er
JOIN elements e ON e.id = er.element_id
WHERE er.source <> 'url'
AND er.resolution = 'unresolved'
AND er.resolution IN ('unresolved', 'ambiguous')
AND er.connector_id IS NULL
"""
).fetchall()