From b9cc340e41ca4d727f355404d1b22994c758c8ce Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 23 Mar 2026 09:37:02 -0700 Subject: [PATCH] Switch from daily to weekly cleanup to cut down on cost of it. --- .../Account/CloudKit/CloudKitAccountDelegate.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift index b38f6d0ef..f5710738e 100644 --- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift +++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift @@ -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")