Handle unhandled error; remove error handling in server-only function (error would never become visible to user)

This commit is contained in:
2025-06-01 12:35:07 -04:00
parent 4dab9f2c93
commit 2e3be57e3e
3 changed files with 8 additions and 13 deletions
+4 -1
View File
@@ -37,7 +37,10 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
return errors.New("unable to refresh entries: \"" + global.EntryRoot + "-old\" already exists") return errors.New("unable to refresh entries: \"" + global.EntryRoot + "-old\" already exists")
} }
} }
os.RemoveAll(global.EntryRoot + dirEnd) err := os.RemoveAll(global.EntryRoot + dirEnd)
if err != nil {
return errors.New("unable to remove \"" + global.EntryRoot + dirEnd + "\": " + err.Error())
}
} }
// create output directory structure (global.EntryRoot + "-new"/*) // create output directory structure (global.EntryRoot + "-new"/*)
+1 -1
View File
@@ -38,7 +38,7 @@ func main() {
case "fetch": case "fetch":
// print all information needed for syncing to stdout for interpretation by the client // print all information needed for syncing to stdout for interpretation by the client
// stdin[0] is expected to be the device ID // stdin[0] is expected to be the device ID
_ = syncserver.GetRemoteDataFromServer(stdin[0]) syncserver.GetRemoteDataFromServer(stdin[0])
case "rename": case "rename":
// move an entry to a new location before using fallthrough to add its previous iteration to the deletions directory // move an entry to a new location before using fallthrough to add its previous iteration to the deletions directory
// stdin[0] is evaluated after fallthrough // stdin[0] is evaluated after fallthrough
+3 -11
View File
@@ -1,7 +1,6 @@
package syncserver package syncserver
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@@ -14,16 +13,10 @@ 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 FSSpace. // Lists in output are separated by FSSpace.
// 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) error { func GetRemoteDataFromServer(clientDeviceID string) {
entryList, dirList, err := synccommon.WalkEntryDir() entryList, dirList, _ := synccommon.WalkEntryDir()
if err != nil {
return errors.New("unable to walk entry directory: " + err.Error())
}
modList := synccommon.GetModTimes(entryList) modList := synccommon.GetModTimes(entryList)
deletionsList, err := os.ReadDir(global.ConfigDir + global.PathSeparator + "deletions") deletionsList, _ := os.ReadDir(global.ConfigDir + global.PathSeparator + "deletions")
if err != nil {
return errors.New("unable to read deletions directory: " + err.Error())
}
// print the current UNIX timestamp to stdout // print the current UNIX timestamp to stdout
fmt.Print(time.Now().Unix()) fmt.Print(time.Now().Unix())
@@ -60,5 +53,4 @@ func GetRemoteDataFromServer(clientDeviceID string) error {
_ = os.Remove(global.ConfigDir + global.PathSeparator + "deletions" + global.PathSeparator + deletion.Name()) // error ignored; function not run from a user-facing argument and thus the error would not be visible _ = os.Remove(global.ConfigDir + global.PathSeparator + "deletions" + global.PathSeparator + deletion.Name()) // error ignored; function not run from a user-facing argument and thus the error would not be visible
} }
} }
return nil
} }