Prevent multiple device records with the same UDID (#422)

This commit is contained in:
Scott Knight
2018-05-27 10:16:30 -04:00
committed by Victor Vrantchan
parent 6507d2edd2
commit 4283b5a76e

View File

@@ -218,7 +218,7 @@ func (db *DB) pollCheckin(pubsubSvc pubsub.PublishSubscriber) error {
fmt.Println(err) // some other issue is going on
continue
}
_, err = db.DeviceByUDID(ev.Command.UDID)
byUDID, err := db.DeviceByUDID(ev.Command.UDID)
if err != nil && isNotFound(err) { // never checked in
fmt.Printf("checking in new device %s\n", ev.Command.SerialNumber)
} else if err != nil {
@@ -226,6 +226,7 @@ func (db *DB) pollCheckin(pubsubSvc pubsub.PublishSubscriber) error {
continue
} else if err == nil {
fmt.Printf("re-enrolling device %s\n", ev.Command.SerialNumber)
newDevice = byUDID
newDevice.Enrolled = false
}