From 2a175d0c691aa76eadf53146500517e959309774 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Fri, 17 May 2024 11:48:06 -0400 Subject: [PATCH] Handle instances where the server does not respond to "fetch" as expected --- 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 5eb7015..7e09f02 100644 --- a/src/sync/client.go +++ b/src/sync/client.go @@ -118,7 +118,11 @@ func getRemoteDataFromClient(manualSync bool) (map[string]int64, []string, []str // split output into slice based on occurrences of "\x1d" outputSlice := strings.Split(output, "\x1d") - // re-form the lists TODO handle error for index out of bounds (occurs if reading deletions directory on server fails) + // re-form the lists + if len(outputSlice) != 4 { // ensure information from server is complete + fmt.Println(backend.AnsiError + "Sync failed - Unable to fetch remote data; server returned an unexpected response" + backend.AnsiReset) + os.Exit(1) + } entries := strings.Split(outputSlice[0], "\x1f")[1:] modsStrings := strings.Split(outputSlice[1], "\x1f")[1:] folders := strings.Split(outputSlice[2], "\x1f")[1:]