Update Account#getNextDeviceId to not reuse disable device’s IDs

This commit is contained in:
Chris Eager
2021-09-09 17:52:45 -07:00
committed by Chris Eager
parent 016141a05d
commit 23a076a204
2 changed files with 31 additions and 8 deletions

View File

@@ -212,17 +212,13 @@ public class Account {
public long getNextDeviceId() {
requireNotStale();
long highestDevice = Device.MASTER_ID;
long candidateId = Device.MASTER_ID + 1;
for (Device device : devices) {
if (!device.isEnabled()) {
return device.getId();
} else if (device.getId() > highestDevice) {
highestDevice = device.getId();
}
while (getDevice(candidateId).isPresent()) {
candidateId++;
}
return highestDevice + 1;
return candidateId;
}
public int getEnabledDeviceCount() {