mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 17:29:23 +00:00
Handle low memory notification.
This commit is contained in:
1 parent
dc27e85ed8
commit
e2a7fd0051
1 file changed
+9
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import os
|
||||
import RSCore
|
||||
import RSParser
|
||||
|
||||
// To get a notification when HTMLMetadata is cached, see HTMLMetadataCache.
|
||||
@@ -22,6 +23,14 @@ nonisolated public final class HTMLMetadataDownloader: Sendable {
|
||||
private let attemptDatesLock = OSAllocatedUnfairLock(initialState: [String: Date]())
|
||||
private let urlsReturning4xxsLock = OSAllocatedUnfairLock(initialState: Set<String>())
|
||||
|
||||
init() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleLowMemory(_:)), name: .lowMemory, object: nil)
|
||||
}
|
||||
|
||||
@objc func handleLowMemory(_ notification: Notification) {
|
||||
cache.removeAll()
|
||||
}
|
||||
|
||||
public func cachedMetadata(for url: String) -> RSHTMLMetadata? {
|
||||
if Self.shouldSkipDownloadingMetadata(url) {
|
||||
Self.logger.debug("HTMLMetadataDownloader: Skipping requested cached metadata for \(url)")
|
||||
|
||||
Reference in new issue
Block a user