diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index 44219001f..a138fea4b 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -226,8 +226,7 @@ struct AppDefaults { let showDebugMenu = false #endif - let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), - Key.sidebarFontSize: FontSize.medium.rawValue, + let defaults: [String : Any] = [Key.sidebarFontSize: FontSize.medium.rawValue, Key.timelineFontSize: FontSize.medium.rawValue, Key.detailFontSize: FontSize.medium.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, diff --git a/Shared/Data/CacheCleaner.swift b/Shared/Data/CacheCleaner.swift index 748f13aa9..949a7eb2e 100644 --- a/Shared/Data/CacheCleaner.swift +++ b/Shared/Data/CacheCleaner.swift @@ -14,9 +14,14 @@ struct CacheCleaner { static let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CacheCleaner") static func purgeIfNecessary() { + + guard let flushDate = AppDefaults.lastImageCacheFlushDate else { + AppDefaults.lastImageCacheFlushDate = Date() + return + } // If the image disk cache hasn't been flushed for 3 days and the network is available, delete it - if let flushDate = AppDefaults.lastImageCacheFlushDate, flushDate.addingTimeInterval(3600*24*3) < Date() { + if flushDate.addingTimeInterval(3600*24*3) < Date() { if let reachability = try? Reachability(hostname: "apple.com") { if reachability.connection != .unavailable { diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 21e636d05..da607f6ec 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -150,8 +150,7 @@ struct AppDefaults { } static func registerDefaults() { - let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), - Key.timelineGroupByFeed: false, + let defaults: [String : Any] = [Key.timelineGroupByFeed: false, Key.refreshClearsReadArticles: false, Key.timelineNumberOfLines: 2, Key.timelineIconSize: IconSize.medium.rawValue,