diff options
author | stephan <stephan@noemail.net> | 2022-06-01 16:04:29 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-06-01 16:04:29 +0000 |
commit | 4e5aeb54f2f1ed96ea32beb52c5098d0c1c01cca (patch) | |
tree | c99d3a5bbca13c4e87fcff0875757585d07fc8b5 /ext/fiddle/sqlite3-api.js | |
parent | 23aa8ff4de91719647d799be469e7409825c6bc6 (diff) | |
download | sqlite-4e5aeb54f2f1ed96ea32beb52c5098d0c1c01cca.tar.gz sqlite-4e5aeb54f2f1ed96ea32beb52c5098d0c1c01cca.zip |
fiddle: added another UI element to the list of those which are disabled during long-running activities. Added DB.close() binding to the Worker-based wasm binding.
FossilOrigin-Name: 5933163ed1a8f996e81023c7c5822655dc6411d30016f37fe8863f760530dc5b
Diffstat (limited to 'ext/fiddle/sqlite3-api.js')
-rw-r--r-- | ext/fiddle/sqlite3-api.js | 29 |
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! |