mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 16:26:04 +00:00
Report per-database duration when vacuuming.
This commit is contained in:
1 parent
1a6ed87632
commit
6fdda05ec3
20 files changed
+120
-61
No files matched your search
@@ -10,14 +10,16 @@ import RSCore
|
||||
import RSDatabase
|
||||
import RSDatabaseObjC
|
||||
|
||||
final actor HTMLMetadataDatabase {
|
||||
public final actor HTMLMetadataDatabase {
|
||||
|
||||
@MainActor static let shared: HTMLMetadataDatabase = {
|
||||
@MainActor public static let shared: HTMLMetadataDatabase = {
|
||||
let databasePath = AppConfig.dataFolder
|
||||
.appendingPathComponent("HTMLMetadata.db").path
|
||||
return HTMLMetadataDatabase(databasePath: databasePath)
|
||||
}()
|
||||
|
||||
public nonisolated let databasePath: String
|
||||
|
||||
private let database: FMDatabase
|
||||
private var cache = [String: CachedRecord]()
|
||||
|
||||
@@ -51,6 +53,7 @@ final actor HTMLMetadataDatabase {
|
||||
private static let transientFailureRetryHours = 5
|
||||
|
||||
private init(databasePath: String) {
|
||||
self.databasePath = databasePath
|
||||
let database = FMDatabase.openAndSetUpDatabase(path: databasePath)
|
||||
database.executeStatements("PRAGMA journal_mode = WAL;")
|
||||
database.runCreateStatements(Self.tableCreationStatements)
|
||||
@@ -71,6 +74,10 @@ final actor HTMLMetadataDatabase {
|
||||
database.vacuumIfNeeded()
|
||||
}
|
||||
|
||||
public func vacuum() {
|
||||
database.vacuum()
|
||||
}
|
||||
|
||||
@objc nonisolated func handleAppDidGoToBackground(_ notification: Notification) {
|
||||
Task {
|
||||
await emptyCache()
|
||||
|
||||
Reference in new issue
Block a user