mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-01 14:47:25 -04:00
Remove old device ID from server in DeviceIDGen
This commit is contained in:
+7
-1
@@ -53,7 +53,8 @@ func GpgKeyGen() string {
|
||||
}
|
||||
|
||||
// DirInit creates the libmutton directories.
|
||||
func DirInit(preserveOldConfigDir bool) {
|
||||
// Returns: oldDeviceID (before from before the directory reset).
|
||||
func DirInit(preserveOldConfigDir bool) string {
|
||||
// create EntryRoot
|
||||
err := os.MkdirAll(EntryRoot, 0700)
|
||||
if err != nil {
|
||||
@@ -61,6 +62,9 @@ func DirInit(preserveOldConfigDir bool) {
|
||||
os.Exit(102)
|
||||
}
|
||||
|
||||
// get old device ID before its potential removal
|
||||
oldDeviceID := (*GenDeviceIDList(false))[0].Name() // errorOnFail set to false to ignore error if device ID directory does not exist (error non-critical for this function)
|
||||
|
||||
// remove existing config directory (if it exists and not in append mode)
|
||||
if !preserveOldConfigDir {
|
||||
_, isAccessible := TargetIsFile(ConfigDir, false, 1)
|
||||
@@ -79,4 +83,6 @@ func DirInit(preserveOldConfigDir bool) {
|
||||
fmt.Println(AnsiError + "Failed to create \"" + ConfigDir + "\": " + err.Error() + AnsiReset)
|
||||
os.Exit(102)
|
||||
}
|
||||
|
||||
return oldDeviceID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user