Skip to content

Commit 24ce7d8

Browse files
jlongsternrakochy
authored andcommitted
Don't delete file on close
1 parent 1e892af commit 24ce7d8

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
@@ -826,6 +826,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
826826
function Database(data, { filename = false } = {}) {
827827
if(filename === false) {
828828
this.filename = "dbfile_" + (0xffffffff * Math.random() >>> 0);
829+
this.memoryFile = true;
829830
if (data != null) {
830831
FS.createDataFile("/", this.filename, data, true, true);
831832
}
@@ -1117,7 +1118,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
11171118
Object.values(this.functions).forEach(removeFunction);
11181119
this.functions = {};
11191120
this.handleError(sqlite3_close_v2(this.db));
1120-
FS.unlink("/" + this.filename);
1121+
1122+
if(this.memoryFile) {
1123+
FS.unlink("/" + this.filename);
1124+
}
11211125
this.db = null;
11221126
};
11231127

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)