Fix iOS expired logs never clearing

This commit is contained in:
advplyr
2026-09-08 17:10:30 -05:00
parent d11d9860b6
commit b706337852
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ PODS:
- Capacitor - Capacitor
- CapacitorPreferences (7.0.1): - CapacitorPreferences (7.0.1):
- Capacitor - Capacitor
- CapacitorStatusBar (7.0.1): - CapacitorStatusBar (7.0.6):
- Capacitor - Capacitor
- CordovaPlugins (6.2.1): - CordovaPlugins (6.2.1):
- CapacitorCordova - CapacitorCordova
@@ -100,7 +100,7 @@ SPEC CHECKSUMS:
CapacitorHaptics: 1f1e17041f435d8ead9ff2a34edd592c6aa6a8d6 CapacitorHaptics: 1f1e17041f435d8ead9ff2a34edd592c6aa6a8d6
CapacitorNetwork: 15cb4385f0913a8ceb5e9a4d7af1ec554bdb8de8 CapacitorNetwork: 15cb4385f0913a8ceb5e9a4d7af1ec554bdb8de8
CapacitorPreferences: 6c98117d4d7508034a4af9db64d6b26fc75d7b94 CapacitorPreferences: 6c98117d4d7508034a4af9db64d6b26fc75d7b94
CapacitorStatusBar: 6e7af040d8fc4dd655999819625cae9c2d74c36f CapacitorStatusBar: 416e9e53fd6397e668d4a181cd2131617d949bd6
CordovaPlugins: 2ecbba09775516c41764dbf78ade612427311b7e CordovaPlugins: 2ecbba09775516c41764dbf78ade612427311b7e
Realm: b1b3bc68162fa242132eb7eefbf91d7c40f36a85 Realm: b1b3bc68162fa242132eb7eefbf91d7c40f36a85
RealmSwift: 456cfd82a4f23dff8e3456980999331ab69bbf3e RealmSwift: 456cfd82a4f23dff8e3456980999331ab69bbf3e
+3 -3
View File
@@ -312,13 +312,13 @@ class Database {
private func cleanExpiredLogs() throws { private func cleanExpiredLogs() throws {
let realm = try Realm() let realm = try Realm()
let numberOfHoursToKeep = 48 let numberOfHoursToKeep = 48
let keepLogCutoff = Date().addingTimeInterval(TimeInterval(-1 * numberOfHoursToKeep * 3600)) let keepLogCutoffMs = Int(Date().addingTimeInterval(TimeInterval(-1 * numberOfHoursToKeep * 3600)).timeIntervalSince1970 * 1000)
let allLogs = getAllLogs() let allLogs = getAllLogs()
var logsRemoved = 0 var logsRemoved = 0
try? realm.write { try? realm.write {
allLogs.forEach { log in allLogs.forEach { log in
if log.timestamp < Int(keepLogCutoff.timeIntervalSince1970) { if log.timestamp < keepLogCutoffMs {
realm.delete(log) realm.delete(log)
logsRemoved += 1 logsRemoved += 1
} }