mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-30 13:39:57 +00:00
Fix bug in unregistering old devices, if the oldest didn't include the id.
This commit is contained in:
@@ -133,15 +133,19 @@ public class RegisterServlet extends HttpServlet {
|
|||||||
// TODO: we should also define a 'ping' message and expire/remove
|
// TODO: we should also define a 'ping' message and expire/remove
|
||||||
// unused registrations
|
// unused registrations
|
||||||
DeviceInfo oldest = registrations.get(0);
|
DeviceInfo oldest = registrations.get(0);
|
||||||
long oldestTime = oldest.getRegistrationTimestamp().getTime();
|
if (oldest.getRegistrationTimestamp() == null) {
|
||||||
for (int i = 1; i < registrations.size(); i++) {
|
pm.deletePersistent(oldest);
|
||||||
if (registrations.get(i).getRegistrationTimestamp().getTime() <
|
} else {
|
||||||
oldestTime) {
|
long oldestTime = oldest.getRegistrationTimestamp().getTime();
|
||||||
oldest = registrations.get(i);
|
for (int i = 1; i < registrations.size(); i++) {
|
||||||
oldestTime = oldest.getRegistrationTimestamp().getTime();
|
if (registrations.get(i).getRegistrationTimestamp().getTime() <
|
||||||
|
oldestTime) {
|
||||||
|
oldest = registrations.get(i);
|
||||||
|
oldestTime = oldest.getRegistrationTimestamp().getTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pm.deletePersistent(oldest);
|
||||||
}
|
}
|
||||||
pm.deletePersistent(oldest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get device if it already exists, else create
|
// Get device if it already exists, else create
|
||||||
|
|||||||
Reference in New Issue
Block a user