Skip to content

Commit c1aea3e

Browse files
committed
Don't delete file on close
1 parent ebc92a0 commit c1aea3e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
818818
function Database(data, { filename = false } = {}) {
819819
if(filename === false) {
820820
this.filename = "dbfile_" + (0xffffffff * Math.random() >>> 0);
821+
this.memoryFile = true;
821822
if (data != null) {
822823
FS.createDataFile("/", this.filename, data, true, true);
823824
}
@@ -1109,7 +1110,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
11091110
Object.values(this.functions).forEach(removeFunction);
11101111
this.functions = {};
11111112
this.handleError(sqlite3_close_v2(this.db));
1112-
FS.unlink("/" + this.filename);
1113+
1114+
if(this.memoryFile) {
1115+
FS.unlink("/" + this.filename);
1116+
}
11131117
this.db = null;
11141118
};
11151119

src/vfs.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ static int block_unlock(sqlite3_file *file, int lock) {
2424
static int block_open(sqlite3_vfs *vfs, const char *zName, sqlite3_file *file, int flags, int *pOutFlags) {
2525
int res = defaultOpen(vfs, zName, file, flags, pOutFlags);
2626

27-
printf("Opened!\n");
28-
2927
sqlite3_io_methods* methods = (sqlite3_io_methods*)file->pMethods;
3028
methods->xDeviceCharacteristics = blockDeviceCharacteristics;
3129
methods->xLock = block_lock;

0 commit comments

Comments
 (0)