There was an error while loading. Please reload this page.
1 parent 7054939 commit 0410920Copy full SHA for 0410920
1 file changed
src/main/kotlin/eu/darken/octi/server/device/DeviceRepo.kt
@@ -71,8 +71,11 @@ class DeviceRepo @Inject constructor(
71
delay(config.deviceGCInterval.toMillis() / 10)
72
while (currentCoroutineContext().isActive) {
73
val now = Instant.now()
74
- devices.forEach { (key, device) ->
75
- if (Duration.between(device.lastSeen, now) < config.deviceExpiration) return@forEach
+ val staleKeys = devices.entries
+ .filter { Duration.between(it.value.lastSeen, now) >= config.deviceExpiration }
76
+ .map { it.key }
77
+
78
+ for (key in staleKeys) {
79
try {
80
log(TAG, WARN) { "Deleting stale device $key" }
81
deleteDevice(key)
0 commit comments