mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Mark opportunities for snapshot creation failure (including #1383)
This commit is contained in:
1 parent
abd3ba39b1
commit
cedcfbe330
2 files changed
+4
No files matched your search
@@ -669,6 +669,7 @@ extension DatabasePool: DatabaseReader {
|
||||
#if SQLITE_ENABLE_SNAPSHOT || (!GRDBCUSTOMSQLITE && !GRDBCIPHER && (compiler(>=5.7.1) || !(os(macOS) || targetEnvironment(macCatalyst))))
|
||||
/// Returns a long-lived WAL snapshot transaction on a reader connection.
|
||||
func walSnapshotTransaction() throws -> WALSnapshotTransaction {
|
||||
// TODO #1383: might fail if wal file is truncated
|
||||
guard let readerPool else {
|
||||
throw DatabaseError.connectionIsClosed()
|
||||
}
|
||||
@@ -687,6 +688,7 @@ extension DatabasePool: DatabaseReader {
|
||||
/// - important: The `completion` argument is executed in a serial
|
||||
/// dispatch queue, so make sure you use the transaction asynchronously.
|
||||
func asyncWALSnapshotTransaction(_ completion: @escaping (Result<WALSnapshotTransaction, Error>) -> Void) {
|
||||
// TODO #1383: might fail if wal file is truncated
|
||||
guard let readerPool else {
|
||||
completion(.failure(DatabaseError.connectionIsClosed()))
|
||||
return
|
||||
@@ -904,6 +906,7 @@ extension DatabasePool {
|
||||
/// if this method is called from a database access where a write
|
||||
/// transaction is open.
|
||||
public func makeSnapshotPool() throws -> DatabaseSnapshotPool {
|
||||
// TODO #1383: might fail if wal file is truncated
|
||||
try unsafeReentrantRead { db in
|
||||
try DatabaseSnapshotPool(db)
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ public final class DatabaseSnapshotPool {
|
||||
/// - configuration: A configuration.
|
||||
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
||||
public init(path: String, configuration: Configuration = Configuration()) throws {
|
||||
// TODO #1383: might fail if wal file is truncated
|
||||
var configuration = Self.configure(configuration)
|
||||
|
||||
// Acquire and hold WAL snapshot
|
||||
|
||||
Reference in new issue
Block a user