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
|
// MARK: - Persistence
|
||||||
|
|
||||||
private static func loadEvents() -> [BLAuditEvent] {
|
private static func loadEvents() -> [BLAuditEvent] {
|
||||||
guard let data = try? Data(contentsOf: fileURL),
|
guard let data = try? Data(contentsOf: fileURL) else { return [] }
|
||||||
let events = try? JSONDecoder().decode([BLAuditEvent].self, from: data) else {
|
let decoder = JSONDecoder()
|
||||||
return []
|
decoder.dateDecodingStrategy = .iso8601
|
||||||
}
|
return (try? decoder.decode([BLAuditEvent].self, from: data)) ?? []
|
||||||
return events
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func saveEvents(_ events: [BLAuditEvent]) {
|
private static func saveEvents(_ events: [BLAuditEvent]) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user