The cacheOrPurgeData function is hitting a fatal error intermittently. I am unable to reproduce the issue while debugging but it is pretty clear in my crash reports.
From what I can see, it would be okay if this function fails silently.
I would like to propose that we swap the fatalError out in favor of an assert and just return inside the guard
Current:
func cacheOrPurgeData(data: Data?, path: String, cacheName: String?, cachingLevel: CachingLevel) {
guard let destinationURL = try? self.destinationURL(for: path, cacheName: cacheName) else {
fatalError("Couldn't get destination URL for path: \(path) and cacheName: \(String(describing: cacheName))")
}
...
}
Proposed solution:
func cacheOrPurgeData(data: Data?, path: String, cacheName: String?, cachingLevel: CachingLevel) {
guard let destinationURL = try? self.destinationURL(for: path, cacheName: cacheName) else {
assertionFailure("Couldn't get destination URL for path: \(path) and cacheName: \(String(describing: cacheName))")
return
}
...
}
The
cacheOrPurgeData
function is hitting a fatal error intermittently. I am unable to reproduce the issue while debugging but it is pretty clear in my crash reports.From what I can see, it would be okay if this function fails silently.
I would like to propose that we swap the
fatalError
out in favor of anassert
and just return inside theguard
Current:
Proposed solution: