Minor cleanups in the opfs-sahpool VFS.

FossilOrigin-Name: 279e09070918dab7b60c39179ebb7eb931ca6bd4e589b414f436740499a2f910
This commit is contained in:
stephan 2023-07-15 21:08:48 +00:00
parent 38d1db9b79
commit 28d46cce0b
4 changed files with 18 additions and 25 deletions

View File

@ -162,7 +162,7 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
*/
const SAHPool = Object.assign(Object.create(null),{
/* OPFS dir in which VFS metadata is stored. */
vfsDir: sqlite3.config['vfs:opfs-sahpool:dir']
vfsDir: sqlite3.config['opfs-sahpool.dir']
|| ".sqlite3-opfs-sahpool",
/* Directory handle to this.vfsDir. */
dirHandle: undefined,
@ -241,7 +241,6 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
await Promise.all(files.map(async ([name,h])=>{
try{
const ah = await h.createSyncAccessHandle()
/*TODO: clean up and fail vfs init on error*/;
this.mapSAHToName.set(ah, name);
const path = this.getAssociatedPath(ah);
if(path){
@ -251,6 +250,7 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
}
}catch(e){
SAHPool.storeErr(e);
this.releaseAccessHandles();
throw e;
}
}));
@ -334,10 +334,6 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
returns it as a two-element Uint32Array.
*/
computeDigest: function(byteArray){
if(!byteArray[0]){
// Deleted file
return new Uint32Array([0xfecc5f80, 0xaccec037]);
}
let h1 = 0xdeadbeef;
let h2 = 0x41c6ce57;
for(const v of byteArray){
@ -346,6 +342,10 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
}
return new Uint32Array([h1>>>0, h2>>>0]);
},
/**
Re-initializes the state of the SAH pool,
releasing and re-acquiring all handles.
*/
reset: async function(){
await this.isReady;
let h = await navigator.storage.getDirectory();
@ -470,13 +470,12 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
return 0;
}catch(e){
SAHPool.storeErr(e);
error("xRead() failed:",e.message);
return capi.SQLITE_IOERR;
}
},
/*xSectorSize: function(pFile){
xSectorSize: function(pFile){
return SECTOR_SIZE;
},*/
},
xSync: function(pFile,flags){
log(`xSync ${flags}`);
SAHPool.storeErr();
@ -487,7 +486,6 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
return 0;
}catch(e){
SAHPool.storeErr(e);
error("xSync() failed:",e.message);
return capi.SQLITE_IOERR;
}
},
@ -501,7 +499,6 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
return 0;
}catch(e){
SAHPool.storeErr(e);
error("xTruncate() failed:",e.message);
return capi.SQLITE_IOERR;
}
},
@ -523,7 +520,6 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
return nBytes === n ? 0 : capi.SQLITE_IOERR;
}catch(e){
SAHPool.storeErr(e);
error("xWrite() failed:",e.message);
return capi.SQLITE_IOERR;
}
}
@ -563,7 +559,6 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
return 0;
}catch(e){
SAHPool.storeErr(e);
error("Error xDelete()ing file:",e.message);
return capi.SQLITE_IOERR_DELETE;
}
},

View File

@ -107,10 +107,8 @@
const S = globalThis.S = sqlite3;
log("Loaded speedtest1 module. Setting up...");
if(S.installOpfsSAHPoolVfs){
await S.installOpfsSAHPoolVfs().then(()=>{
log("Loaded SAHPool.");
}).catch(e=>{
logErr("Error setting up SAHPool:",e.message);
await S.installOpfsSAHPoolVfs().catch(e=>{
logErr("Error setting up opfs-sahpool:",e.message);
});
}
App.vfsUnlink = function(pDb, fname){

View File

@ -1,5 +1,5 @@
C Correct\sopfs-sahpool\sVFS\safter\sthe\spebkac\sinvolving\sthe\sprevious\sspeedtest1\sruns.\sMake\sthat\sVFS\sexplicitly\sopt-in\sto\savoid\scertain\sunfortunate\slocking\ssituations.
D 2023-07-15T19:08:58.138
C Minor\scleanups\sin\sthe\sopfs-sahpool\sVFS.
D 2023-07-15T21:08:48.986
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -502,7 +502,7 @@ F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b17386
F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
F ext/wasm/api/sqlite3-opfs-async-proxy.js 961bbc3ccc1fa4e91d6519a96e8811ad7ae60173bd969fee7775dacb6eee1da2
F ext/wasm/api/sqlite3-v-helper.js e5c202a9ecde9ef818536d3f5faf26c03a1a9f5192b1ddea8bdabf30d75ef487
F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js 83388ead4bfc489bee008298ab51948ccb75227795ce8d1634f2eec8e02548f1
F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js 0032097c168c8fe7e753abc5b35e65323116d04b0dbaaa97176604660b7bb98c
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js a5c3195203e6085d7aa89fae4b84cf3f3eec4ff4f928c6d0e5d3ef8b14cbc1c0
F ext/wasm/api/sqlite3-wasm.c 12a096d8e58a0af0589142bae5a3c27a0c7e19846755a1a37d2c206352fbedda
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f
@ -540,7 +540,7 @@ F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd84223150
F ext/wasm/speedtest1-wasmfs.html 0e9d335a9b5b5fafe6e1bc8dc0f0ca7e22e6eb916682a2d7c36218bb7d67379d
F ext/wasm/speedtest1-wasmfs.mjs ac5cadbf4ffe69e9eaac8b45e8523f030521e02bb67d654c6eb5236d9c456cbe
F ext/wasm/speedtest1-worker.html bbcf1e7fd79541040c1a7ca2ebf1cb7793ddaf9900d6bde1784148f11b807c34
F ext/wasm/speedtest1-worker.js 4de92e4e6718b8bd1cdecb75af62739d1115fa66656a700b0b51822c848948f5
F ext/wasm/speedtest1-worker.js 554b0985f791758e40ff2b1a04b771e315ab84b4e26b4b8a1c7a5ba968086c45
F ext/wasm/speedtest1.html ff048b4a623aa192e83e143e48f1ce2a899846dd42c023fdedc8772b6e3f07da
F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
@ -2044,8 +2044,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 676ffe6280c1ce787b04d0cdb4a0664229c6125c601af4b18d1bfa125aac3675
R bca4913f68935c8abed9e461aac753fd
P 41bf1fe31f2f3d0daa2bac25dc57262a4b90f22fed6fa97e4e92467c32ae02dc
R a6cacf00d5cb9e3eccf543ab6eefecd8
U stephan
Z 2546a1c8fd9c0ca0c4fd392086704b47
Z d51af2a044894ea09e404a3df277218e
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
41bf1fe31f2f3d0daa2bac25dc57262a4b90f22fed6fa97e4e92467c32ae02dc
279e09070918dab7b60c39179ebb7eb931ca6bd4e589b414f436740499a2f910