From 6725bedc64423b019e44bae39b940f6c91648a7e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 13 Mar 2024 21:03:52 -0700 Subject: [PATCH] Fix several build errors. --- .../Feedly/FeedlyAccountDelegate.swift | 14 +++++++----- .../NewsBlurAccountDelegate+Internal.swift | 12 ++++++---- .../NewsBlur/NewsBlurAccountDelegate.swift | 2 +- ArticlesDatabase/Package.swift | 22 +++++++++---------- .../ArticlesDatabaseCompatibility.swift | 8 +++---- .../Sources/SyncDatabase/SyncDatabase.swift | 2 +- 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift b/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift index 4de0bee54..23618d1c2 100644 --- a/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift +++ b/Account/Sources/Account/Feedly/FeedlyAccountDelegate.swift @@ -95,8 +95,8 @@ final class FeedlyAccountDelegate: AccountDelegate { self.caller = FeedlyAPICaller(transport: session, api: api, secretsProvider: secretsProvider) } - let databaseFilePath = (dataFolder as NSString).appendingPathComponent("Sync.sqlite3") - self.database = SyncDatabase(databaseFilePath: databaseFilePath) + let databasePath = (dataFolder as NSString).appendingPathComponent("Sync.sqlite3") + self.database = SyncDatabase(databasePath: databasePath) self.oauthAuthorizationClient = api.oauthAuthorizationClient(secretsProvider: secretsProvider) self.caller.delegate = self @@ -554,13 +554,17 @@ final class FeedlyAccountDelegate: AccountDelegate { /// Suspend the SQLLite databases func suspendDatabase() { - database.suspend() + Task { + await database.suspend() + } } /// Make sure no SQLite databases are open and we are ready to issue network requests. func resume() { - database.resume() - caller.resume() + Task { + await database.resume() + caller.resume() + } } } diff --git a/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift b/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift index 7f76f07f8..fa6eab17c 100644 --- a/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift +++ b/Account/Sources/Account/NewsBlur/Internals/NewsBlurAccountDelegate+Internal.swift @@ -296,13 +296,17 @@ extension NewsBlurAccountDelegate { apiCall(storyHashGroup) { result in switch result { case .success: - self.database.deleteSelectedForProcessing(storyHashGroup.map { String($0) } ) - group.leave() + Task { + try? await self.database.deleteSelectedForProcessing(storyHashGroup.map { String($0) } ) + group.leave() + } case .failure(let error): errorOccurred = true os_log(.error, log: self.log, "Story status sync call failed: %@.", error.localizedDescription) - self.database.resetSelectedForProcessing(storyHashGroup.map { String($0) } ) - group.leave() + Task { + try? await self.database.resetSelectedForProcessing(storyHashGroup.map { String($0) } ) + group.leave() + } } } } diff --git a/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift b/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift index fbdac4289..727e34a05 100644 --- a/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift +++ b/Account/Sources/Account/NewsBlur/NewsBlurAccountDelegate.swift @@ -55,7 +55,7 @@ final class NewsBlurAccountDelegate: AccountDelegate { caller = NewsBlurAPICaller(transport: session) } - database = SyncDatabase(databaseFilePath: dataFolder.appending("/DB.sqlite3")) + database = SyncDatabase(databasePath: dataFolder.appending("/DB.sqlite3")) } func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) { diff --git a/ArticlesDatabase/Package.swift b/ArticlesDatabase/Package.swift index 82990966a..c7dac9c3e 100644 --- a/ArticlesDatabase/Package.swift +++ b/ArticlesDatabase/Package.swift @@ -3,25 +3,25 @@ import PackageDescription let package = Package( - name: "ArticlesDatabase", + name: "ArticlesDatabase", platforms: [.macOS(.v14), .iOS(.v17)], - products: [ - .library( - name: "ArticlesDatabase", + products: [ + .library( + name: "ArticlesDatabase", type: .dynamic, - targets: ["ArticlesDatabase"]), - ], - dependencies: [ + targets: ["ArticlesDatabase"]), + ], + dependencies: [ .package(url: "https://github.com/Ranchero-Software/RSCore.git", .upToNextMinor(from: "1.0.0")), .package(url: "https://github.com/Ranchero-Software/RSParser.git", .upToNextMajor(from: "2.0.2")), .package(path: "../Articles"), .package(path: "../Database"), .package(path: "../FMDB"), ], - targets: [ - .target( - name: "ArticlesDatabase", - dependencies: [ + targets: [ + .target( + name: "ArticlesDatabase", + dependencies: [ "RSCore", "Database", "RSParser", diff --git a/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabaseCompatibility.swift b/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabaseCompatibility.swift index 523dfc89c..ba79ead30 100644 --- a/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabaseCompatibility.swift +++ b/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabaseCompatibility.swift @@ -16,19 +16,19 @@ import Articles // It will go away as we adopt structured concurrency. public typealias UnreadCountDictionaryCompletionResult = Result -public typealias UnreadCountDictionaryCompletionBlock = (UnreadCountDictionaryCompletionResult) -> Void +public typealias UnreadCountDictionaryCompletionBlock = @Sendable (UnreadCountDictionaryCompletionResult) -> Void public typealias SingleUnreadCountResult = Result -public typealias SingleUnreadCountCompletionBlock = (SingleUnreadCountResult) -> Void +public typealias SingleUnreadCountCompletionBlock = @Sendable (SingleUnreadCountResult) -> Void public typealias UpdateArticlesResult = Result -public typealias UpdateArticlesCompletionBlock = (UpdateArticlesResult) -> Void +public typealias UpdateArticlesCompletionBlock = @Sendable (UpdateArticlesResult) -> Void public typealias ArticleSetResult = Result, DatabaseError> public typealias ArticleSetResultBlock = (ArticleSetResult) -> Void public typealias ArticleIDsResult = Result, DatabaseError> -public typealias ArticleIDsCompletionBlock = (ArticleIDsResult) -> Void +public typealias ArticleIDsCompletionBlock = @Sendable (ArticleIDsResult) -> Void public typealias ArticleStatusesResult = Result, DatabaseError> public typealias ArticleStatusesResultBlock = (ArticleStatusesResult) -> Void diff --git a/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift b/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift index 9b4adcf1e..9a9937265 100644 --- a/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift +++ b/SyncDatabase/Sources/SyncDatabase/SyncDatabase.swift @@ -102,7 +102,7 @@ public actor SyncDatabase { #endif } - func resume() { + public func resume() { #if os(iOS) if database == nil { self.database = FMDatabase.openAndSetUpDatabase(path: databasePath)