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 {
134134
135135 /// Loads and decodes the stored heartbeats bundle from a given storage object.
136136 /// - 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 ? {
139140 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+ }
142147 }
143148
144149 /// Saves the encoding of the given value to the given storage container.
You can’t perform that action at this time.
0 commit comments