Skip to content

Commit 320a002

Browse files
authored
Fix platform-specific errors on tvOS, Linux (#240)
1 parent 441202d commit 320a002

File tree

4 files changed

+57
-55
lines changed

4 files changed

+57
-55
lines changed
File renamed without changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#if canImport(CloudKit)
2+
import Dependencies
3+
4+
package struct UserDatabase {
5+
package let database: any DatabaseWriter
6+
package init(database: any DatabaseWriter) {
7+
self.database = database
8+
}
9+
10+
var path: String {
11+
database.path
12+
}
13+
14+
var configuration: Configuration {
15+
database.configuration
16+
}
17+
18+
package func write<T: Sendable>(
19+
_ updates: @Sendable (Database) throws -> T
20+
) async throws -> T {
21+
try await database.write { db in
22+
try $_isSynchronizingChanges.withValue(true) {
23+
try updates(db)
24+
}
25+
}
26+
}
27+
28+
package func read<T: Sendable>(
29+
_ updates: @Sendable (Database) throws -> T
30+
) async throws -> T {
31+
try await database.read { db in
32+
try updates(db)
33+
}
34+
}
35+
36+
@_disfavoredOverload
37+
package func write<T>(
38+
_ updates: (Database) throws -> T
39+
) throws -> T {
40+
try database.write { db in
41+
try $_isSynchronizingChanges.withValue(true) {
42+
try updates(db)
43+
}
44+
}
45+
}
46+
47+
@_disfavoredOverload
48+
package func read<T>(
49+
_ updates: (Database) throws -> T
50+
) throws -> T {
51+
try database.read { db in
52+
try updates(db)
53+
}
54+
}
55+
}
56+
#endif

Sources/SQLiteData/CloudKit/PrimaryKeyMigration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import CryptoKit
33
import Foundation
44

5-
@available(iOS 17, macOS 14, tvOS 14, watchOS 10, *)
5+
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
66
extension SyncEngine {
77
/// Migrates integer primary-keyed tables and tables without primary keys to
88
/// CloudKit-compatible, UUID primary keys.

Sources/SQLiteData/Internal/UserDatabase.swift

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)