From a0ac99ff3ca7be6f36abd44ae28cef441b0c50ee Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Fri, 17 May 2024 12:32:05 -0400 Subject: [PATCH] Ensure a device ID exists when sending a "fetch" command to libmuttonserver --- src/sync/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sync/client.go b/src/sync/client.go index b074db0..3596b3e 100644 --- a/src/sync/client.go +++ b/src/sync/client.go @@ -112,7 +112,11 @@ func GetSSHOutput(cmd string, manualSync bool) string { func getRemoteDataFromClient(manualSync bool) (map[string]int64, []string, []string) { // get remote output over SSH clientDeviceID, _ := os.ReadDir(backend.ConfigDir + backend.PathSeparator + "devices") - output := GetSSHOutput("libmuttonserver fetch "+clientDeviceID[0].Name(), manualSync) // TODO fix potential index error if clientDeviceID was not configured + if len(clientDeviceID) == 0 { + fmt.Println(backend.AnsiError + "Sync failed - No device ID found; run \"mutn init\" to generate a device ID" + backend.AnsiReset) + os.Exit(1) + } + output := GetSSHOutput("libmuttonserver fetch "+clientDeviceID[0].Name(), manualSync) // split output into slice based on occurrences of "\x1d" outputSlice := strings.Split(output, "\x1d")