aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/sqlite3-opfs-async-proxy.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-09-18 17:32:35 +0000
committerstephan <stephan@noemail.net>2022-09-18 17:32:35 +0000
commitf38601206997aa909b2cd6dba02cb0b4e13e8e2a (patch)
tree7968c95b16ea078621e051c56bfd46b7e1197ce7 /ext/wasm/sqlite3-opfs-async-proxy.js
parent0db3089576b6df43fa477100446ab330b5bda905 (diff)
downloadsqlite-f38601206997aa909b2cd6dba02cb0b4e13e8e2a.tar.gz
sqlite-f38601206997aa909b2cd6dba02cb0b4e13e8e2a.zip
Numerous cleanups in the JS bits. Removed some now-defunct wasm test files. Expose sqlite3.opfs object containing various OPFS-specific utilities.
FossilOrigin-Name: 26e625d05d9820033b23536f18ad3ddc59ed712ad507d4b0c7fe88abd15d2be8
Diffstat (limited to 'ext/wasm/sqlite3-opfs-async-proxy.js')
-rw-r--r--ext/wasm/sqlite3-opfs-async-proxy.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/ext/wasm/sqlite3-opfs-async-proxy.js b/ext/wasm/sqlite3-opfs-async-proxy.js
index 00b402556..5969962d7 100644
--- a/ext/wasm/sqlite3-opfs-async-proxy.js
+++ b/ext/wasm/sqlite3-opfs-async-proxy.js
@@ -164,7 +164,7 @@ const vfsAsyncImpls = {
storeAndNotify(opName, state.sq3Codes.SQLITE_NOFOUND);
}
},
- xDelete: async function({filename, syncDir/*ignored*/}){
+ xDeleteNoWait: async function({filename, syncDir, recursive = false}){
/* The syncDir flag is, for purposes of the VFS API's semantics,
ignored here. However, if it has the value 0x1234 then: after
deleting the given file, recursively try to delete any empty
@@ -178,12 +178,13 @@ const vfsAsyncImpls = {
is false.
*/
log("xDelete(",arguments[0],")");
+ let rc = 0;
try {
while(filename){
const [hDir, filenamePart] = await getDirForPath(filename, false);
//log("Removing:",hDir, filenamePart);
if(!filenamePart) break;
- await hDir.removeEntry(filenamePart);
+ await hDir.removeEntry(filenamePart, {recursive});
if(0x1234 !== syncDir) break;
filename = getResolvedPath(filename, true);
filename.pop();
@@ -193,8 +194,23 @@ const vfsAsyncImpls = {
/* Ignoring: _presumably_ the file can't be found or a dir is
not empty. */
//error("Delete failed",filename, e.message);
+ rc = state.sq3Codes.SQLITE_IOERR_DELETE;
+ }
+ return rc;
+ },
+ xDelete: async function(...args){
+ const rc = await vfsAsyncImpls.xDeleteNoWait(...args);
+ storeAndNotify('xDelete', rc);
+ },
+ mkdir: async function(dirname){
+ let rc = 0;
+ try {
+ await getDirForPath(dirname+"/filepart", true);
+ }catch(e){
+ //error("mkdir failed",filename, e.message);
+ rc = state.sq3Codes.SQLITE_IOERR;
}
- storeAndNotify('xDelete', 0);
+ storeAndNotify('mkdir', rc);
},
xFileSize: async function(fid){
log("xFileSize(",arguments,")");