Add reset-ts endpoint to reset last_sync_ts without clearing sync_map
All checks were successful
Deploy / deploy (push) Successful in 14s

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 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 21:44:27 +01:00
parent 098c1e633b
commit e660808640

View File

@@ -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."""