mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-30 22:06:32 -04:00
Enforce more consistent meanings for the various field separator characters
This commit is contained in:
+2
-2
@@ -143,8 +143,8 @@ func getRemoteDataFromClient(manualSync bool) (map[string]int64, []string, []str
|
|||||||
}
|
}
|
||||||
output := GetSSHOutput("libmuttonserver fetch", clientDeviceID[0].Name(), manualSync)
|
output := GetSSHOutput("libmuttonserver fetch", clientDeviceID[0].Name(), manualSync)
|
||||||
|
|
||||||
// split output into slice based on occurrences of "\x1d"
|
// split output into slice based on occurrences of "\x1e"
|
||||||
outputSlice := strings.Split(output, "\x1d")
|
outputSlice := strings.Split(output, "\x1e")
|
||||||
|
|
||||||
// re-form the lists
|
// re-form the lists
|
||||||
if len(outputSlice) != 4 { // ensure information from server is complete
|
if len(outputSlice) != 4 { // ensure information from server is complete
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ func ShearLocal(targetLocationIncomplete, clientDeviceID string) string {
|
|||||||
if onServer {
|
if onServer {
|
||||||
for _, device := range deviceIDList {
|
for _, device := range deviceIDList {
|
||||||
if device.Name() != clientDeviceID {
|
if device.Name() != clientDeviceID {
|
||||||
_, err = os.Create(backend.ConfigDir + backend.PathSeparator + "deletions" + backend.PathSeparator + device.Name() + "\x1d" + strings.ReplaceAll(targetLocationIncomplete, "/", "\x1e"))
|
_, err = os.Create(backend.ConfigDir + backend.PathSeparator + "deletions" + backend.PathSeparator + device.Name() + "\x1e" + strings.ReplaceAll(targetLocationIncomplete, "/", "\x1d"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// do not print error as there is currently no way of seeing server-side errors
|
// do not print error as there is currently no way of seeing server-side errors
|
||||||
// failure to add the target to the deletions list will exit the program and result in a client re-uploading the target (non-critical)
|
// failure to add the target to the deletions list will exit the program and result in a client re-uploading the target (non-critical)
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ func DeviceIDGen() (string, string) {
|
|||||||
|
|
||||||
// register device ID with server and fetch remote EntryRoot and OS type
|
// register device ID with server and fetch remote EntryRoot and OS type
|
||||||
//manualSync is true so the user is alerted if device ID registration fails
|
//manualSync is true so the user is alerted if device ID registration fails
|
||||||
sshEntryRootSSHIsWindows := strings.Split(GetSSHOutput("libmuttonserver register", deviceID, true), "\x1f")
|
sshEntryRootSSHIsWindows := strings.Split(GetSSHOutput("libmuttonserver register", deviceID, true), "\x1e")
|
||||||
|
|
||||||
return sshEntryRootSSHIsWindows[0], sshEntryRootSSHIsWindows[1]
|
return sshEntryRootSSHIsWindows[0], sshEntryRootSSHIsWindows[1]
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetRemoteDataFromServer prints to stdout the remote entries, mod times, folders, and deletions
|
// GetRemoteDataFromServer prints to stdout the remote entries, mod times, folders, and deletions
|
||||||
// lists in output are separated by "\x1d"
|
// lists in output are separated by "\x1e"
|
||||||
// output is meant to be captured over SSH for interpretation by the client
|
// output is meant to be captured over SSH for interpretation by the client
|
||||||
func GetRemoteDataFromServer(clientDeviceID string) {
|
func GetRemoteDataFromServer(clientDeviceID string) {
|
||||||
entryList, dirList := WalkEntryDir()
|
entryList, dirList := WalkEntryDir()
|
||||||
@@ -27,25 +27,25 @@ func GetRemoteDataFromServer(clientDeviceID string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// modification time list
|
// modification time list
|
||||||
fmt.Print("\x1d")
|
fmt.Print("\x1e")
|
||||||
for _, mod := range modList {
|
for _, mod := range modList {
|
||||||
fmt.Print("\x1f")
|
fmt.Print("\x1f")
|
||||||
fmt.Print(mod)
|
fmt.Print(mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
// directory/folder list
|
// directory/folder list
|
||||||
fmt.Print("\x1d")
|
fmt.Print("\x1e")
|
||||||
for _, dir := range dirList {
|
for _, dir := range dirList {
|
||||||
fmt.Print("\x1f" + dir)
|
fmt.Print("\x1f" + dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletions list
|
// deletions list
|
||||||
fmt.Print("\x1d")
|
fmt.Print("\x1e")
|
||||||
for _, deletion := range deletionsList {
|
for _, deletion := range deletionsList {
|
||||||
// print deletion if it is relevant to the current client device
|
// print deletion if it is relevant to the current client device
|
||||||
affectedIDTargetLocationIncomplete := strings.Split(deletion.Name(), "\x1d")
|
affectedIDTargetLocationIncomplete := strings.Split(deletion.Name(), "\x1e")
|
||||||
if affectedIDTargetLocationIncomplete[0] == clientDeviceID {
|
if affectedIDTargetLocationIncomplete[0] == clientDeviceID {
|
||||||
fmt.Print("\x1f" + strings.ReplaceAll(affectedIDTargetLocationIncomplete[1], "\x1e", "/"))
|
fmt.Print("\x1f" + strings.ReplaceAll(affectedIDTargetLocationIncomplete[1], "\x1d", "/"))
|
||||||
|
|
||||||
// assume successful client deletion and remove deletions file (if assumption is somehow false, worst case scenario is that the client will re-upload the deleted entry)
|
// assume successful client deletion and remove deletions file (if assumption is somehow false, worst case scenario is that the client will re-upload the deleted entry)
|
||||||
os.Remove(backend.ConfigDir + backend.PathSeparator + "deletions" + backend.PathSeparator + deletion.Name())
|
os.Remove(backend.ConfigDir + backend.PathSeparator + "deletions" + backend.PathSeparator + deletion.Name())
|
||||||
|
|||||||
Reference in New Issue
Block a user