File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
FirebaseCore/Internal/Sources/HeartbeatLogging Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,16 @@ final class HeartbeatStorage: HeartbeatStorageProtocol {
134
134
135
135
/// Loads and decodes the stored heartbeats bundle from a given storage object.
136
136
/// - Parameter storage: The storage container to read from.
137
- /// - Returns: The decoded `HeartbeatsBundle` that is loaded from storage.
138
- private func load( from storage: Storage ) throws -> HeartbeatsBundle {
137
+ /// - Returns: The decoded `HeartbeatsBundle` loaded from storage; `nil` if storage is empty.
138
+ /// - Throws: An error if storage could not be read or the data could not be decoded.
139
+ private func load( from storage: Storage ) throws -> HeartbeatsBundle ? {
139
140
let data = try storage. read ( )
140
- let heartbeatData = try data. decoded ( using: decoder) as HeartbeatsBundle
141
- return heartbeatData
141
+ if data. isEmpty {
142
+ return nil
143
+ } else {
144
+ let heartbeatData = try data. decoded ( using: decoder) as HeartbeatsBundle
145
+ return heartbeatData
146
+ }
142
147
}
143
148
144
149
/// Saves the encoding of the given value to the given storage container.
You can’t perform that action at this time.
0 commit comments