diff --git a/internal/api/handlers_syncpairs.go b/internal/api/handlers_syncpairs.go index 79ae23d..61e56e0 100644 --- a/internal/api/handlers_syncpairs.go +++ b/internal/api/handlers_syncpairs.go @@ -75,8 +75,8 @@ func (h *SyncPairHandler) Create(w http.ResponseWriter, r *http.Request) { writeError(w, http.StatusBadRequest, "direction must be push, pull, or mirror") return } - if req.SourceMachineID != nil && req.DestMachineID != nil { - writeError(w, http.StatusBadRequest, "both source and destination cannot be remote machines; one side must be the server (set one MachineID to null)") + if req.SourceMachineID != nil && req.DestMachineID != nil && *req.SourceMachineID == *req.DestMachineID { + writeError(w, http.StatusBadRequest, "source and destination cannot be the same machine") return } if req.RsyncFlags == "" { @@ -131,8 +131,8 @@ func (h *SyncPairHandler) Update(w http.ResponseWriter, r *http.Request) { writeError(w, http.StatusBadRequest, "direction must be push, pull, or mirror") return } - if req.SourceMachineID != nil && req.DestMachineID != nil { - writeError(w, http.StatusBadRequest, "both source and destination cannot be remote machines; one side must be the server (set one MachineID to null)") + if req.SourceMachineID != nil && req.DestMachineID != nil && *req.SourceMachineID == *req.DestMachineID { + writeError(w, http.StatusBadRequest, "source and destination cannot be the same machine") return } diff --git a/web/src/pages/SyncPairs.tsx b/web/src/pages/SyncPairs.tsx index d21f398..4e57a03 100644 --- a/web/src/pages/SyncPairs.tsx +++ b/web/src/pages/SyncPairs.tsx @@ -111,6 +111,14 @@ export default function SyncPairs() { toast.error('Source and destination paths are required'); return; } + if ( + form.source_machine_id !== null && + form.dest_machine_id !== null && + form.source_machine_id === form.dest_machine_id + ) { + toast.error('Source and destination cannot be the same machine'); + return; + } setLoading(true); try { await api(form.id ? `/api/sync-pairs/${form.id}` : '/api/sync-pairs', { @@ -325,6 +333,9 @@ export default function SyncPairs() { ))} +

+ Where the data lives. Pick Local server if it's on this machine, otherwise the remote machine holding the data. +

@@ -346,6 +357,9 @@ export default function SyncPairs() { ))} +

+ Where to copy the data. Can be the same machine (no-op) or any remote. Remote-to-remote is supported. +