Skip to content

Migrate save sync to use server-side negotiate API#163

Draft
gantoine wants to merge 1 commit intomainfrom
server-save-sync
Draft

Migrate save sync to use server-side negotiate API#163
gantoine wants to merge 1 commit intomainfrom
server-save-sync

Conversation

@gantoine
Copy link
Member

Replaces client-side save sync resolution with the (under development) server-side negotiate API (POST /api/sync/negotiate) from rommapp/romm#3137.

What changed

Before: grout fetched remote saves per-ROM (N concurrent GET /api/saves calls), ran its own conflict detection by comparing local mtimes against DeviceSyncs.LastSyncedAt, and separately discovered remote-only saves.

After: grout scans local saves, computes MD5 content hashes, and sends everything to the server in a single negotiate call. The server determines upload/download/conflict/no_op actions and returns a sync session. Grout executes the plan and marks the session complete.

Changes

  • romm/sync.go (new): API types and client methods for negotiate/complete endpoints
  • romm/saves.go: Added session_id to upload/download queries. + moved MarkDeviceSynced/ConfirmSaveDownloaded
    • Server now handles device sync state automatically via device_id on uploads and optimistic=true on downloads
  • internal/fileutil/fileutil.go: Added ComputeMD5 matching the server's content hash algorithm
  • sync/flow.go (rewritten): ResolveSaveSync now calls negotiate instead of doing client-side resolution, and ExecuteSaveSync tracks session lifecycle
  • sync/execute.go (extracted from flow.go): Upload/download execution with session ID pass-through
  • sync/scan.go (extracted from flow.go): Local save scanning and slot selection

Removed

  • Client-side conflict detection (determineAction, DetermineActions)
  • Per-ROM remote save fetching (FetchRemoteSaves, DiscoverRemoteSaves`)
  • Helper functions (LocalSavesWithoutRemote, NewSaveUploadActions)
  • MarkDeviceSynced / ConfirmSaveDownloaded / endpointSaveDownloaded

Requires rommapp/romm#3137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant