mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-31 14:26:36 -04:00
Parse deletions per-deviceID
This commit is contained in:
+10
-2
@@ -4,12 +4,13 @@ import (
|
||||
"fmt"
|
||||
"github.com/rwinkhart/MUTN/src/backend"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetRemoteDataFromServer prints to stdout the remote entries, mod times, folders, and deletions
|
||||
// lists in output are separated by "\x1d"
|
||||
// output is meant to be captured over SSH for interpretation by the client
|
||||
func GetRemoteDataFromServer() {
|
||||
func GetRemoteDataFromServer(clientDeviceID string) {
|
||||
entryList, dirList := WalkEntryDir()
|
||||
modList := getModTimes(entryList)
|
||||
deletionsList, err := os.ReadDir(backend.ConfigDir + backend.PathSeparator + "deletions")
|
||||
@@ -33,6 +34,13 @@ func GetRemoteDataFromServer() {
|
||||
}
|
||||
fmt.Print("\x1d")
|
||||
for _, deletion := range deletionsList {
|
||||
fmt.Print("\x1f" + deletion.Name())
|
||||
// print deletion if it is relevant to the current client device
|
||||
affectedIDTargetLocationIncomplete := strings.Split(deletion.Name(), "\x1d")
|
||||
if affectedIDTargetLocationIncomplete[0] == clientDeviceID {
|
||||
fmt.Print("\x1f" + strings.ReplaceAll(affectedIDTargetLocationIncomplete[1], "\x1e", backend.PathSeparator))
|
||||
|
||||
// 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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user