Handle error for failing to create local device ID file

This commit is contained in:
2024-06-05 18:29:38 -04:00
parent 779d9d0c78
commit 349cd49e4d
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -1,6 +1,7 @@
package sync
import (
"fmt"
"github.com/rwinkhart/MUTN/src/backend"
"math/rand"
"os"
@@ -14,7 +15,10 @@ func DeviceIDGen() (string, string) {
deviceIDPrefix, _ := os.Hostname()
deviceIDSuffix := backend.StringGen(rand.Intn(48)+48, false, 0) // TODO consider using complex string generator and removing unsafe characters manually
deviceID := deviceIDPrefix + "-" + deviceIDSuffix
os.Create(backend.ConfigDir + backend.PathSeparator + "devices" + backend.PathSeparator + deviceID) // TODO remove existing device ID file if it exists (from both client and server)
_, err := os.Create(backend.ConfigDir + backend.PathSeparator + "devices" + backend.PathSeparator + deviceID) // TODO remove existing device ID file if it exists (from both client and server)
if err != nil {
fmt.Println(backend.AnsiError + "Failed to create local device ID file: " + err.Error() + backend.AnsiReset)
}
// 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