aboutsummaryrefslogtreecommitdiff
path: root/backup.go
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2014-07-12 23:38:18 +0900
committermattn <mattn.jp@gmail.com>2014-07-12 23:38:18 +0900
commitf87f73cc9a9604ce0557a40fc153d7eb7a7584a7 (patch)
tree5524058a5df9dc7a1541d94941baf803ba4a151d /backup.go
parentUpgrade amalgamation code (diff)
parentChanged interface for backup step (diff)
downloadgolite-f87f73cc9a9604ce0557a40fc153d7eb7a7584a7.tar.gz
golite-f87f73cc9a9604ce0557a40fc153d7eb7a7584a7.tar.xz
Merge pull request #130 from shuhaowu/sqlite-backup-step-done-check
Added an IsDone method for backup
Diffstat (limited to 'backup.go')
-rw-r--r--backup.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/backup.go b/backup.go
index 2684cc0..ab56961 100644
--- a/backup.go
+++ b/backup.go
@@ -25,12 +25,18 @@ func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*Backup,
return nil, c.lastError()
}
-func (b *Backup) Step(p int) error {
+// Backs up for one step. Calls the underlying `sqlite3_backup_step` function.
+// This function returns a boolean indicating if the backup is done and
+// an error signalling any other error. Done is returned if the underlying C
+// function returns SQLITE_DONE (Code 101)
+func (b *Backup) Step(p int) (bool, error) {
ret := C.sqlite3_backup_step(b.b, C.int(p))
- if ret != 0 {
- return Error{Code: ErrNo(ret)}
+ if ret == 101 {
+ return true, nil
+ } else if ret != 0 {
+ return false, Error{Code: ErrNo(ret)}
}
- return nil
+ return false, nil
}
func (b *Backup) Remaining() int {