From e66080864077cd83fd390dd6d156545cb5bf2aa0 Mon Sep 17 00:00:00 2001 From: domverse Date: Sun, 22 Mar 2026 21:44:27 +0100 Subject: [PATCH] Add reset-ts endpoint to reset last_sync_ts without clearing sync_map Needed to safely recover missing docs: run reconcile first (populates sync_map for existing docs), then reset-ts, then sync (only missing docs get uploaded, existing ones get metadata patch only). Co-Authored-By: Claude Sonnet 4.6 --- app/api/replicas.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/api/replicas.py b/app/api/replicas.py index 772939f..e6fd0b0 100644 --- a/app/api/replicas.py +++ b/app/api/replicas.py @@ -176,6 +176,18 @@ def unsuspend_replica(replica_id: int, session: Session = Depends(get_session)): return _serialize(replica) +@router.post("/{replica_id}/reset-ts") +def reset_replica_sync_ts(replica_id: int, session: Session = Depends(get_session)): + """Reset last_sync_ts to None so the next sync fetches all master docs. Does NOT touch sync_map.""" + replica = session.get(Replica, replica_id) + if not replica: + raise HTTPException(404) + replica.last_sync_ts = None + session.add(replica) + session.commit() + return {"ok": True, "replica_id": replica_id} + + @router.post("/{replica_id}/resync") async def resync_replica(replica_id: int, session: Session = Depends(get_session)): """Wipe sync_map, reset last_sync_ts, and trigger a full resync."""