Skip to content

Commit 4aa37f6

Browse files
committed
Expert users need raw access to expert values
1 parent 3757152 commit 4aa37f6

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

GRDB/Core/Database.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,11 +1320,12 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
13201320
do {
13211321
backupLoop: while true {
13221322
let rc = sqlite3_backup_step(backup, pagesPerStep)
1323-
let totalPages = Int(sqlite3_backup_pagecount(backup))
1324-
let completedPages = totalPages - Int(sqlite3_backup_remaining(backup))
1325-
let progress = DatabaseBackupProgress(completedPageCount: completedPages,
1326-
totalPageCount: totalPages,
1327-
isCompleted: rc == SQLITE_DONE)
1323+
let totalPageCount = Int(sqlite3_backup_pagecount(backup))
1324+
let remainingPageCount = Int(sqlite3_backup_remaining(backup))
1325+
let progress = DatabaseBackupProgress(
1326+
remainingPageCount: remainingPageCount,
1327+
totalPageCount: totalPageCount,
1328+
isCompleted: rc == SQLITE_DONE)
13281329
switch rc {
13291330
case SQLITE_DONE:
13301331
try? afterBackupStep?(progress)

GRDB/Core/DatabaseBackupProgress.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
///
55
/// This is an advanced API for expert users. It is based directly on the SQLite
66
/// [online backup API](https://www.sqlite.org/c3ref/backup_finish.html).
7-
///
8-
/// This struct is not meant to be instantiated by users.
97
public struct DatabaseBackupProgress {
10-
/// Completed page count is defined as `sqlite3_backup_pagecount() - sqlite3_backup_remaining()`
11-
public let completedPageCount: Int
8+
/// Total page count is defined by the `sqlite3_backup_remaining` function
9+
public let remainingPageCount: Int
10+
1211
/// Total page count is defined by the `sqlite3_backup_pagecount` function
1312
public let totalPageCount: Int
13+
14+
/// Completed page count is defined as `sqlite3_backup_pagecount() - sqlite3_backup_remaining()`
15+
public var completedPageCount: Int {
16+
totalPageCount - remainingPageCount
17+
}
18+
1419
/// This property is true if and only if `sqlite3_backup_step()` returns
1520
/// `SQLITE_DONE`
1621
public let isCompleted: Bool

0 commit comments

Comments
 (0)