Add detail to activity log for downloading HTML Metadata — say when the last download was. Also: made the HTML Metadata cache hold for 149 hours (about six days; was 73).

This commit is contained in:
Brent Simmons committed 2026-06-13 14:32:43 -07:00
1 parent ebfc7cf4fe
commit 3ae9156ff3
4 files changed
+24 -3

No files matched your search

@@ -45,8 +45,8 @@ public final actor HTMLMetadataDatabase {
CREATE TABLE IF NOT EXISTS metadata (url TEXT PRIMARY KEY NOT NULL, lastChecked REAL NOT NULL, statusCode INTEGER NOT NULL DEFAULT 200, favicons TEXT, appleTouchIcons TEXT, feedLinks TEXT, openGraphImages TEXT, twitterImageURL TEXT);
"""
/// 73 hours — prime number close to 3 days.
private static let cacheExpirationHours = 73
/// 149 hours — prime number close to 6 days.
private static let cacheExpirationHours = 149
private static let maximumDaysWithoutCheck = 30
private static let persistentFailureRetryDays = 11
@@ -117,6 +117,14 @@ public final actor HTMLMetadataDatabase {
return cached.record
}
/// The date metadata was last successfully downloaded for this URL, or nil if there's no successful record.
func lastDownloadDate(for url: String) -> Date? {
guard let cached = cachedOrFetched(url), !cached.isFailure, cached.record != nil else {
return nil
}
return cached.lastChecked
}
/// True if the last contact failed recently (4xx or transient).
func recentlyFailed(for url: String) -> Bool {
guard let cached = cachedOrFetched(url) else {