mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 16:26:04 +00:00
Call FMDatabase(extras).vacuum, which now does logging, so we know how long it takes.
This commit is contained in:
1 parent
8cf466028a
commit
84e3167282
1 file changed
+1
-13
@@ -9,12 +9,9 @@ import Foundation
|
||||
import RSCore
|
||||
import RSDatabase
|
||||
import RSDatabaseObjC
|
||||
import os
|
||||
|
||||
public actor ErrorLogDatabase {
|
||||
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ErrorLogDatabase")
|
||||
|
||||
private let database: FMDatabase
|
||||
|
||||
private static let tableCreationStatements = "CREATE TABLE if not EXISTS errors (id INTEGER PRIMARY KEY AUTOINCREMENT, date REAL NOT NULL, sourceName TEXT NOT NULL, sourceID INTEGER NOT NULL, operation TEXT NOT NULL DEFAULT '', fileName TEXT NOT NULL DEFAULT '', functionName TEXT NOT NULL DEFAULT '', lineNumber INTEGER NOT NULL DEFAULT 0, errorMessage TEXT NOT NULL);"
|
||||
@@ -26,7 +23,7 @@ public actor ErrorLogDatabase {
|
||||
database.executeStatements("PRAGMA journal_mode = WAL;")
|
||||
database.runCreateStatements(Self.tableCreationStatements)
|
||||
ErrorLogTable.pruneEntries(limit: Self.pruneLimit, database: database)
|
||||
Self.vacuum(database: database)
|
||||
database.vacuum()
|
||||
|
||||
self.database = database
|
||||
|
||||
@@ -43,15 +40,6 @@ public actor ErrorLogDatabase {
|
||||
ErrorLogTable.allEntries(database: database)
|
||||
}
|
||||
|
||||
// MARK: - Maintenance
|
||||
|
||||
private static func vacuum(database: FMDatabase) {
|
||||
let start = CFAbsoluteTimeGetCurrent()
|
||||
database.executeStatements("VACUUM;")
|
||||
let duration = CFAbsoluteTimeGetCurrent() - start
|
||||
logger.debug("ErrorLogDatabase: VACUUM took \(duration, format: .fixed(precision: 4)) seconds")
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc nonisolated func handleAppDidEncounterError(_ notification: Notification) {
|
||||
|
||||
Reference in new issue
Block a user