mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Documentation, cleanup
This commit is contained in:
1 parent
9215f88e7f
commit
ec0e8672be
1 file changed
+17
-8
@@ -947,14 +947,23 @@ extension DatabasePool: DatabaseReader {
|
||||
do {
|
||||
// Transaction is needed for version snapshotting
|
||||
try db.inTransaction(.deferred) {
|
||||
var fetchNeeded = true
|
||||
withExtendedLifetime(initialSnapshot) {
|
||||
if let initialVersion = initialSnapshot.version {
|
||||
do {
|
||||
fetchNeeded = try db.wasChanged(since: initialVersion)
|
||||
} catch {
|
||||
// ignore: we'll just re-fetch
|
||||
}
|
||||
// Keep DatabaseSnaphot alive until we have compared
|
||||
// database versions. It prevents database checkpointing,
|
||||
// and keeps versions (`sqlite3_snapshot`) valid
|
||||
// and comparable.
|
||||
let fetchNeeded: Bool = withExtendedLifetime(initialSnapshot) {
|
||||
// Version is nil if SQLite is not compiled with
|
||||
// SQLITE_ENABLE_SNAPSHOT, or if the DatabaseSnaphot
|
||||
// could not grab its version. In this case, we don't
|
||||
// care, and just fetch a fresh value.
|
||||
guard let initialVersion = initialSnapshot.version else {
|
||||
return true
|
||||
}
|
||||
do {
|
||||
return try db.wasChanged(since: initialVersion)
|
||||
} catch {
|
||||
// ignore: we'll just re-fetch
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user