diff --git a/global/init.go b/global/init.go index 79c29ef..624cb98 100644 --- a/global/init.go +++ b/global/init.go @@ -19,7 +19,7 @@ func DirInit(preserveOldConfigDir bool) (string, error) { // get old device ID before its potential removal oldDeviceID, err := GetCurrentDeviceID() if err != nil { - return "", errors.New("unable to get current device ID: " + err.Error()) + oldDeviceID = FSMisc } // remove existing config directory (if it exists and not in append mode) diff --git a/synccycles/init.go b/synccycles/init.go index 8a2a8a4..370e41a 100644 --- a/synccycles/init.go +++ b/synccycles/init.go @@ -35,10 +35,12 @@ func DeviceIDGen(oldDeviceID string) (string, string, error) { cleanupOnFail := func() { // remove new device ID file os.RemoveAll(newDeviceIDPath) - // restore old device ID file (if it has already been removed due to DirInit) - if isAccessible, _ := back.TargetIsFile(oldDeviceIDPath, true); !isAccessible { - f, _ := os.OpenFile(oldDeviceIDPath, os.O_CREATE|os.O_WRONLY, 0600) - _ = f.Close() // error ignored; if the file could be created, it can probably be closed + if oldDeviceID != global.FSMisc { + // restore old device ID file (if it existed and has already been removed due to DirInit) + if isAccessible, _ := back.TargetIsFile(oldDeviceIDPath, true); !isAccessible { + f, _ := os.OpenFile(oldDeviceIDPath, os.O_CREATE|os.O_WRONLY, 0600) + _ = f.Close() // error ignored; if the file could be created, it can probably be closed + } } }