Switch from daily to weekly cleanup to cut down on cost of it.

This commit is contained in:
Brent Simmons committed 2026-03-23 09:37:02 -07:00
1 parent 8df4016d81
commit b9cc340e41
1 file changed
+4 -4
@@ -871,8 +871,8 @@ private extension CloudKitAccountDelegate {
func cleanUpContentRecordsIfNeeded() async {
let lastCleanUp = UserDefaults.standard.object(forKey: Self.lastCleanUpKey) as? Date ?? .distantPast
let oneDayAgo = Date(timeIntervalSinceNow: -24 * 60 * 60)
guard lastCleanUp < oneDayAgo else {
let oneWeekAgo = Date(timeIntervalSinceNow: -7 * 24 * 60 * 60)
guard lastCleanUp < oneWeekAgo else {
return
}
@@ -884,11 +884,11 @@ private extension CloudKitAccountDelegate {
// doing a bunch of extra work that will fail. Let it rest until the next go.
UserDefaults.standard.set(Date(), forKey: Self.lastCleanUpKey)
Self.logger.info("CloudKitAccountDelegate: running daily record cleanup")
Self.logger.info("CloudKitAccountDelegate: running weekly record cleanup")
do {
let syncUnreadContent = Self.syncArticleContentForUnreadArticles
let deleted = try await articlesZone.cleanUpRecords(account: account, syncUnreadContent: syncUnreadContent, dryRun: true)
Self.logger.info("CloudKitAccountDelegate: daily cleanup deleted \(deleted, privacy: .public) records")
Self.logger.info("CloudKitAccountDelegate: weekly cleanup deleted \(deleted, privacy: .public) records")
} catch {
Self.logger.error("CloudKitAccountDelegate: daily cleanup error: \(error.localizedDescription, privacy: .public)")
postSyncError(error, account: account, operation: "Daily record cleanup")