mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-29 13:26:38 -04:00
Handle error for failing to create local device ID file
This commit is contained in:
+5
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user