fix(swift-sdk): match date decoding strategy in BLAuditLogger
saveEvents used .iso8601 encoding but loadEvents used the default decoder (.deferredToDate). ISO8601 date strings could not be decoded back, causing loadEvents() to return [] after the first log — breaking event rotation and losing all previous audit entries.
This commit is contained in:
parent
b4be39888b
commit
ae55616444
@ -67,11 +67,10 @@ public enum BLAuditLogger {
|
||||
// MARK: - Persistence
|
||||
|
||||
private static func loadEvents() -> [BLAuditEvent] {
|
||||
guard let data = try? Data(contentsOf: fileURL),
|
||||
let events = try? JSONDecoder().decode([BLAuditEvent].self, from: data) else {
|
||||
return []
|
||||
}
|
||||
return events
|
||||
guard let data = try? Data(contentsOf: fileURL) else { return [] }
|
||||
let decoder = JSONDecoder()
|
||||
decoder.dateDecodingStrategy = .iso8601
|
||||
return (try? decoder.decode([BLAuditEvent].self, from: data)) ?? []
|
||||
}
|
||||
|
||||
private static func saveEvents(_ events: [BLAuditEvent]) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user