Skip to content

Commit

Permalink
Close the database before reading its contents
Browse files Browse the repository at this point in the history
In Database.export, the contents of the database has to be flushed to
the db file before the contents of the file are read and returned.

Fix #9
Fix #55
  • Loading branch information
lovasoa committed Sep 27, 2014
1 parent e16ae3c commit 1ee5a18
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions coffee/api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,13 @@ class Database
### Exports the contents of the database to a binary array
@return [Uint8Array] An array of bytes of the SQLite3 database file
###
'export': -> FS.readFile @filename, encoding:'binary'

'export': ->
stmt['free']() for _,stmt of @statements
@handleError sqlite3_close_v2 @db
binaryDb = FS.readFile @filename, encoding:'binary'
@handleError sqlite3_open @filename, apiTemp
@db = getValue apiTemp, 'i32'
binaryDb

### Close the database, and all associated prepared statements.
Expand Down

0 comments on commit 1ee5a18

Please sign in to comment.