From e49a7d8f0a2ddb7a7a36ee473471b501b489fa23 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 4 Jun 2024 15:57:00 -0400 Subject: [PATCH] Server stdin migration: shear --- libmuttonserver.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libmuttonserver.go b/libmuttonserver.go index 2959ae8..a411ea8 100644 --- a/libmuttonserver.go +++ b/libmuttonserver.go @@ -41,15 +41,17 @@ func main() { switch args[1] { case "fetch": // print all information needed for syncing to stdout for interpretation by the client + // stdin[0] is expected to be the device ID sync.GetRemoteDataFromServer(stdin[0]) case "shear": // shear an entry from the server and add it to the deletions directory - deviceIDTargetLocation := strings.Split(args[2], "\x1d") - targetLocationIncomplete := strings.ReplaceAll(strings.ReplaceAll(deviceIDTargetLocation[1], "\x1f", " "), "\x1e", backend.PathSeparator) - sync.ShearLocal(targetLocationIncomplete, deviceIDTargetLocation[0]) + // stdin[0] is expected to be the device ID + // stdin[1] is expected to be the incomplete target location with "\x1d" representing path separators - always pass in UNIX format + sync.ShearLocal(strings.ReplaceAll(stdin[1], "\x1d", "/"), stdin[0]) case "addfolder": - // add a new folder to the server (using information from stdin) - sync.AddFolderLocal(strings.ReplaceAll(stdin[0], "\x1d", backend.PathSeparator)) + // add a new folder to the server + // stdin[0] is expected to be the incomplete target location with "\x1d" representing path separators - always pass in UNIX format + sync.AddFolderLocal(strings.ReplaceAll(stdin[0], "\x1d", "/")) case "register": // register a new device ID os.Create(backend.ConfigDir + backend.PathSeparator + "devices" + backend.PathSeparator + args[2])