♻️ refactor(sync): extract shared target-table resolution

This commit is contained in:
Misaka_Company
2026-07-15 14:03:19 +08:00
parent 706b9c33db
commit 5ca0715801
4 changed files with 97 additions and 19 deletions

View File

@@ -22,6 +22,7 @@ from .config import load_config, FileMapping, SyncConfig
from .access_reader import AccessReader
from .sql_writer import SqlWriter
from .logging_setup import setup_logging
from .targets import resolve_synced_tables
log = logging.getLogger("sync.fullsync")
@@ -29,21 +30,11 @@ log = logging.getLogger("sync.fullsync")
def resolve_tables(reader: AccessReader, fm: FileMapping) -> list[str]:
"""Tables to fully sync for one file, after exclude/include rules.
Mirrors the precedence used by ``capture.capture_file``: a table in
``exclude_tables`` is dropped even if it also appears in ``include_tables``.
System tables (``MSys*`` / ``~*``) are already filtered by
``AccessReader.list_user_tables``.
Thin wrapper over ``targets.resolve_synced_tables`` so fullsync, capture
and compare share one resolution path. System tables (``MSys*`` / ``~*``)
are already filtered by ``AccessReader.list_user_tables``.
"""
exclude = set(fm.exclude_tables or [])
include = set(fm.include_tables) if fm.include_tables else None
out = []
for t in reader.list_user_tables():
if t in exclude:
continue
if include is not None and t not in include:
continue
out.append(t)
return out
return resolve_synced_tables(fm, reader)
def full_sync_file(fm: FileMapping, reader: AccessReader, writer: SqlWriter) -> dict: