diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift
index b6fd00418..c209e6479 100644
--- a/Mac/AppDelegate.swift
+++ b/Mac/AppDelegate.swift
@@ -772,6 +772,12 @@ extension AppDelegate {
NotificationCenter.default.post(name: .WebInspectorEnabledDidChange, object: newValue)
}
+ @IBAction func vacuumDatabases(_ sender: Any?) {
+ Task {
+ await AccountManager.shared.vacuumAllDatabases()
+ }
+ }
+
@IBAction func showiCloudDriveMissingAlert(_ sender: Any?) {
// Manual testing for alert in AccountsAddCloudKitWindowController
// Check for:
diff --git a/Mac/Base.lproj/Main.storyboard b/Mac/Base.lproj/Main.storyboard
index 3f20bf4a8..d34e77a53 100644
--- a/Mac/Base.lproj/Main.storyboard
+++ b/Mac/Base.lproj/Main.storyboard
@@ -548,6 +548,13 @@
+
+
diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift
index 8cfd86c33..71fde7cf4 100644
--- a/Modules/Account/Sources/Account/Account.swift
+++ b/Modules/Account/Sources/Account/Account.swift
@@ -1029,6 +1029,14 @@ public enum FetchType {
postChildrenDidChangeNotification()
}
+ // MARK: - Vacuum
+
+ public func vacuumDatabases() {
+ database.vacuum()
+ feedSettingsDatabase.vacuum()
+ delegate.vacuumDatabases()
+ }
+
// MARK: - Debug
public func debugDropConditionalGetInfo() {
diff --git a/Modules/Account/Sources/Account/AccountDelegate.swift b/Modules/Account/Sources/Account/AccountDelegate.swift
index 897f34aec..297f20f3a 100644
--- a/Modules/Account/Sources/Account/AccountDelegate.swift
+++ b/Modules/Account/Sources/Account/AccountDelegate.swift
@@ -53,6 +53,8 @@ import Secrets
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?) async throws -> Credentials?
+ func vacuumDatabases()
+
/// Suspend all network activity
func suspendNetwork()
diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift
index 699ddebb0..b453ff071 100644
--- a/Modules/Account/Sources/Account/AccountManager.swift
+++ b/Modules/Account/Sources/Account/AccountManager.swift
@@ -417,6 +417,15 @@ import ErrorLog
return count
}
+ // MARK: - Vacuum
+
+ public func vacuumAllDatabases() async {
+ await errorLogDatabase.vacuum()
+ for account in accounts {
+ account.vacuumDatabases()
+ }
+ }
+
// MARK: - Caches
/// Empty caches that can reasonably be emptied — when the app moves to the background, for instance.
diff --git a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift
index f35f55c7e..99aafd673 100644
--- a/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift
+++ b/Modules/Account/Sources/Account/CloudKit/CloudKitAccountDelegate.swift
@@ -472,6 +472,12 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable {
nil
}
+ func vacuumDatabases() {
+ Task {
+ await syncDatabase.vacuum()
+ }
+ }
+
// MARK: - Suspend and Resume (for iOS)
func suspendNetwork() {
diff --git a/Modules/Account/Sources/Account/FeedSettingsDatabase.swift b/Modules/Account/Sources/Account/FeedSettingsDatabase.swift
index 9c7afe3e9..461e053ec 100644
--- a/Modules/Account/Sources/Account/FeedSettingsDatabase.swift
+++ b/Modules/Account/Sources/Account/FeedSettingsDatabase.swift
@@ -64,6 +64,10 @@ import Articles
}
}
+ func vacuum() {
+ database.vacuum()
+ }
+
var isEmpty: Bool {
guard let resultSet = database.executeQuery("SELECT 1 FROM feedSettings LIMIT 1;", withArgumentsIn: []) else {
return true
diff --git a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift
index fe7b263bb..caa2231ce 100644
--- a/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift
+++ b/Modules/Account/Sources/Account/Feedbin/FeedbinAccountDelegate.swift
@@ -374,6 +374,12 @@ public enum FeedbinAccountDelegateError: String, Error, Sendable {
return try await caller.validateCredentials()
}
+ func vacuumDatabases() {
+ Task {
+ await syncDatabase.vacuum()
+ }
+ }
+
// MARK: Suspend and Resume (for iOS)
/// Suspend all network activity
diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift
index 9dda56621..52991fcfc 100644
--- a/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift
+++ b/Modules/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift
@@ -680,6 +680,12 @@ import Secrets
return credentials
}
+ func vacuumDatabases() {
+ Task {
+ await syncDatabase.vacuum()
+ }
+ }
+
// MARK: Suspend and Resume (for iOS)
/// Suspend all network activity
diff --git a/Modules/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift b/Modules/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift
index 8a8c513da..c59e31c65 100644
--- a/Modules/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift
+++ b/Modules/Account/Sources/Account/LocalAccount/LocalAccountDelegate.swift
@@ -140,6 +140,9 @@ import Secrets
nil
}
+ func vacuumDatabases() {
+ }
+
// MARK: Suspend and Resume (for iOS)
@MainActor func suspendNetwork() {
diff --git a/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift b/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift
index 0b04d1a36..4a86dfcaa 100644
--- a/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift
+++ b/Modules/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift
@@ -447,6 +447,12 @@ import Secrets
return try await caller.validateCredentials()
}
+ func vacuumDatabases() {
+ Task {
+ await syncDatabase.vacuum()
+ }
+ }
+
// MARK: - Suspend and Resume (for iOS)
/// Suspend all network activity
diff --git a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift
index 24ce6dc15..e70eae6dc 100644
--- a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift
+++ b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift
@@ -500,6 +500,12 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
return try await caller.validateCredentials(endpoint: endpoint)
}
+ func vacuumDatabases() {
+ Task {
+ await syncDatabase.vacuum()
+ }
+ }
+
// MARK: Suspend and Resume (for iOS)
/// Suspend all network activity
diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift
index 5f3bcc493..01db2b02f 100644
--- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift
+++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift
@@ -79,6 +79,12 @@ public struct ArticleChanges: Sendable {
}
}
+ // MARK: - Vacuum
+
+ public func vacuum() {
+ queue.vacuum()
+ }
+
// MARK: - Fetching Articles
public func fetchArticles(feedID: String) throws -> Set {
diff --git a/Modules/ErrorLog/Sources/ErrorLog/ErrorLogDatabase.swift b/Modules/ErrorLog/Sources/ErrorLog/ErrorLogDatabase.swift
index 972202258..7e11642e1 100644
--- a/Modules/ErrorLog/Sources/ErrorLog/ErrorLogDatabase.swift
+++ b/Modules/ErrorLog/Sources/ErrorLog/ErrorLogDatabase.swift
@@ -36,6 +36,10 @@ public actor ErrorLogDatabase {
ErrorLogTable.insertEntry(sourceName: sourceName, sourceID: sourceID, operation: operation, fileName: fileName, functionName: functionName, lineNumber: lineNumber, errorMessage: errorMessage, database: database)
}
+ public func vacuum() {
+ database.vacuum()
+ }
+
public func allEntries() -> [ErrorLogEntry] {
ErrorLogTable.allEntries(database: database)
}
diff --git a/Modules/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift b/Modules/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift
index 509111916..c262c35ec 100644
--- a/Modules/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift
+++ b/Modules/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift
@@ -28,6 +28,10 @@ public actor SyncDatabase {
// MARK: - API
+ public func vacuum() {
+ database?.vacuum()
+ }
+
public func insertStatuses(_ statuses: Set) throws {
guard let database else {
throw DatabaseError.isSuspended