Skip to content

Commit 1ee5a18

Browse files
committed
Close the database before reading its contents
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
1 parent e16ae3c commit 1ee5a18

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: coffee/api.coffee

+7-2
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,13 @@ class Database
374374
### Exports the contents of the database to a binary array
375375
@return [Uint8Array] An array of bytes of the SQLite3 database file
376376
###
377-
'export': -> FS.readFile @filename, encoding:'binary'
378-
377+
'export': ->
378+
stmt['free']() for _,stmt of @statements
379+
@handleError sqlite3_close_v2 @db
380+
binaryDb = FS.readFile @filename, encoding:'binary'
381+
@handleError sqlite3_open @filename, apiTemp
382+
@db = getValue apiTemp, 'i32'
383+
binaryDb
379384

380385
### Close the database, and all associated prepared statements.
381386

0 commit comments

Comments
 (0)