aboutsummaryrefslogtreecommitdiff
path: root/ext/fiddle/sqlite3-api.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fiddle/sqlite3-api.js')
-rw-r--r--ext/fiddle/sqlite3-api.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/ext/fiddle/sqlite3-api.js b/ext/fiddle/sqlite3-api.js
index 943f1bc8e..1be4d9c77 100644
--- a/ext/fiddle/sqlite3-api.js
+++ b/ext/fiddle/sqlite3-api.js
@@ -461,7 +461,7 @@ Module.postRun.push(function(namespace/*the module object, the target for
delete this._pDb;
if(this.filename){
if(alsoUnlink){
- try{SQM.FS.unlink(this.filename);}
+ try{SQM.FS.unlink('/'+this.filename);}
catch(e){/*ignored*/}
}
delete this.filename;
@@ -1530,9 +1530,9 @@ Module.postRun.push(function(namespace/*the module object, the target for
else if(this.db) this.db.close();
return this.db = (Array.isArray(arg) ? new DB(...arg) : new DB(arg));
},
- close: function(){
+ close: function(alsoUnlink){
if(this.db){
- this.db.close();
+ this.db.close(alsoUnlink);
this.db = undefined;
}
},
@@ -1679,9 +1679,30 @@ Module.postRun.push(function(namespace/*the module object, the target for
}
const db = wState.open(args);
return {filename: db.filename};
+ },
+ /**
+ Proxy for DB.close(). If ev.data may either be a boolean or
+ an object with an `unlink` property. If that value is
+ truthy then the db file (if the db is currently open) will
+ be unlinked from the virtual filesystem, else it will be
+ kept intact. The response object is:
+
+ {filename: db filename _if_ the db is is opened when this
+ is called, else the undefined value
+ }
+ */
+ close: function(ev){
+ const response = {
+ filename: wState.db && wState.db.filename
+ };
+ if(wState.db){
+ wState.close(!!(ev.data && 'object'===typeof ev.data)
+ ? ev.data.unlink : ev.data);
+ }
+ return response;
}
}/*wMsgHandler*/;
-
+
/**
UNDER CONSTRUCTION!