aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-opfs-async-proxy.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2024-03-11 09:34:38 +0000
committerstephan <stephan@noemail.net>2024-03-11 09:34:38 +0000
commit88abf9ad44f65654e50a47c0f4a9f6e66eeff349 (patch)
tree3f4b1095df46a7767a5db233176a3766c165b66f /ext/wasm/api/sqlite3-opfs-async-proxy.js
parent5007833f5f82d33c95f44c65fc46221de1c5950f (diff)
parentbf030d53b14bc38fbdc745636ef8dffdd57a1fa0 (diff)
downloadsqlite-88abf9ad44f65654e50a47c0f4a9f6e66eeff349.tar.gz
sqlite-88abf9ad44f65654e50a47c0f4a9f6e66eeff349.zip
Add delete-before-open=1 URI flag to the 'opfs' VFS to tell it to xDelete the db file before opening it, primarily to enable users to work around a corrupt db without having to reach into OPFS-specific APIs to remove the db file.
FossilOrigin-Name: e87cf0d7700d33a439c91725460fbfe3a1765b48f71b4d73c38cadf6c166e0bd
Diffstat (limited to 'ext/wasm/api/sqlite3-opfs-async-proxy.js')
-rw-r--r--ext/wasm/api/sqlite3-opfs-async-proxy.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js
index cafd296c6..58b8bcb23 100644
--- a/ext/wasm/api/sqlite3-opfs-async-proxy.js
+++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js
@@ -562,6 +562,17 @@ const installAsyncProxy = function(self){
wTimeEnd();
return;
}
+ if( state.opfsFlags.OPFS_UNLINK_BEFORE_OPEN & opfsFlags ){
+ //log("async proxy opfsFlags =",opfsFlags);
+ try{
+ await hDir.removeEntry(filenamePart);
+ //log("Unlinked",filename,hDir,filenamePart);
+ }
+ catch(e){
+ /* ignoring */
+ //warn("Ignoring failed Unlink of",filename,":",e);
+ }
+ }
const hFile = await hDir.getFileHandle(filenamePart, {create});
wTimeEnd();
const fh = Object.assign(Object.create(null),{