mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-28 00:04:25 +00:00
Remove no-longer-needed code for suspending and resuming SQLite databases on iOS.
This commit is contained in:
1 parent
395593401d
commit
8f4a979608
22 files changed
+105
-315
No files matched your search
@@ -11,7 +11,7 @@ import RSDatabase
|
||||
import RSDatabaseObjC
|
||||
|
||||
public actor SyncDatabase {
|
||||
private var database: FMDatabase?
|
||||
private let database: FMDatabase
|
||||
public nonisolated let databasePath: String
|
||||
|
||||
public init(databasePath: String) {
|
||||
@@ -26,81 +26,42 @@ public actor SyncDatabase {
|
||||
// MARK: - API
|
||||
|
||||
public func vacuum() {
|
||||
database?.vacuum()
|
||||
database.vacuum()
|
||||
}
|
||||
|
||||
public func insertStatuses(_ statuses: Set<SyncStatus>) throws {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
public func insertStatuses(_ statuses: Set<SyncStatus>) {
|
||||
SyncStatusTable.insertStatuses(statuses, database: database)
|
||||
}
|
||||
|
||||
public func selectForProcessing(limit: Int? = nil) throws -> Set<SyncStatus>? {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
return SyncStatusTable.selectForProcessing(limit: limit, database: database)
|
||||
public func selectForProcessing(limit: Int? = nil) -> Set<SyncStatus>? {
|
||||
SyncStatusTable.selectForProcessing(limit: limit, database: database)
|
||||
}
|
||||
|
||||
public func selectPendingCount() throws -> Int? {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
return SyncStatusTable.selectPendingCount(database: database)
|
||||
public func selectPendingCount() -> Int? {
|
||||
SyncStatusTable.selectPendingCount(database: database)
|
||||
}
|
||||
|
||||
public func selectPendingReadStatusArticleIDs() throws -> Set<String>? {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
return SyncStatusTable.selectPendingReadStatusArticleIDs(database: database)
|
||||
public func selectPendingReadStatusArticleIDs() -> Set<String>? {
|
||||
SyncStatusTable.selectPendingReadStatusArticleIDs(database: database)
|
||||
}
|
||||
|
||||
public func selectPendingStarredStatusArticleIDs() throws -> Set<String>? {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
return SyncStatusTable.selectPendingStarredStatusArticleIDs(database: database)
|
||||
public func selectPendingStarredStatusArticleIDs() -> Set<String>? {
|
||||
SyncStatusTable.selectPendingStarredStatusArticleIDs(database: database)
|
||||
}
|
||||
|
||||
nonisolated public func resetAllSelectedForProcessing() {
|
||||
Task {
|
||||
try? await _resetAllSelectedForProcessing()
|
||||
await _resetAllSelectedForProcessing()
|
||||
}
|
||||
}
|
||||
|
||||
public func resetSelectedForProcessing(_ articleIDs: Set<String>) throws {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
public func resetSelectedForProcessing(_ articleIDs: Set<String>) {
|
||||
SyncStatusTable.resetSelectedForProcessing(articleIDs, database: database)
|
||||
}
|
||||
|
||||
public func deleteSelectedForProcessing(_ articleIDs: Set<String>) throws {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
public func deleteSelectedForProcessing(_ articleIDs: Set<String>) {
|
||||
SyncStatusTable.deleteSelectedForProcessing(articleIDs, database: database)
|
||||
}
|
||||
|
||||
// MARK: - Suspend and Resume (for iOS)
|
||||
|
||||
nonisolated public func suspend() {
|
||||
#if os(iOS)
|
||||
Task {
|
||||
await _suspend()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nonisolated public func resume() {
|
||||
#if os(iOS)
|
||||
Task {
|
||||
await _resume()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -111,25 +72,7 @@ private extension SyncDatabase {
|
||||
CREATE TABLE if not EXISTS syncStatus (articleID TEXT NOT NULL, key TEXT NOT NULL, flag BOOL NOT NULL DEFAULT 0, selected BOOL NOT NULL DEFAULT 0, PRIMARY KEY (articleID, key));
|
||||
"""
|
||||
|
||||
func _resetAllSelectedForProcessing() throws {
|
||||
guard let database else {
|
||||
throw DatabaseError.isSuspended
|
||||
}
|
||||
func _resetAllSelectedForProcessing() {
|
||||
SyncStatusTable.resetAllSelectedForProcessing(database: database)
|
||||
}
|
||||
|
||||
func _suspend() {
|
||||
#if os(iOS)
|
||||
database?.close()
|
||||
database = nil
|
||||
#endif
|
||||
}
|
||||
|
||||
func _resume() {
|
||||
#if os(iOS)
|
||||
if database == nil {
|
||||
self.database = FMDatabase.openAndSetUpDatabase(path: databasePath)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user