1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Reformulate the forceReinitIfFailed handling based on feedback, to correct the type-checking and resolve a potential race condition.

FossilOrigin-Name: c4f468309158f9b951137461213fb269d96d15c331256cf392a56c9bed231460
This commit is contained in:
stephan
2024-07-11 19:50:17 +00:00
parent 9958c51a5d
commit 8ee747dda5
4 changed files with 22 additions and 17 deletions

View File

@ -1225,13 +1225,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
throw options.$testThrowPhase1;
}
if(initPromises[vfsName]){
const p = initPromises[vfsName];
if( (p instanceof OpfsSAHPool) || !options.forceReinitIfFailed ){
//log("Returning cached installOpfsSAHPoolVfs() result",options,vfsName,initPromises[vfsName]);
try {
const p = await initPromises[vfsName];
//log("installOpfsSAHPoolVfs() returning cached result",options,vfsName,p);
return p;
}catch(e){
//log("installOpfsSAHPoolVfs() got cached failure",options,vfsName,e);
if( options.forceReinitIfFailed ){
delete initPromises[vfsName];
/* Fall through and try again. */
}else{
throw e;
}
}
delete initPromises[vfsName];
/* Fall through and try again. */
}
if(!globalThis.FileSystemHandle ||
!globalThis.FileSystemDirectoryHandle ||