1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Replace time-based auto-unlock of opfs sync handles with lock acquisition/release via sqlite3_io_methods::xLock/xUnlock().

FossilOrigin-Name: 2625b7cfe1640c1d7e779ec1f37db970541598c0dc3e22e5eecf3c772d95ad40
This commit is contained in:
stephan
2022-10-04 17:06:51 +00:00
parent ed3182f233
commit 9a55773b2f
6 changed files with 115 additions and 72 deletions

View File

@ -34,10 +34,6 @@ const tryOpfsVfs = async function(sqlite3){
const wait = async (ms)=>{
return new Promise((resolve)=>setTimeout(resolve, ms));
};
const waitForRelinquish = async ()=>{
log("Waiting briefly to test sync handle relinquishing...");
return wait(1500);
};
const urlArgs = new URL(self.location.href).searchParams;
const dbFile = "my-persistent.db";
@ -45,13 +41,11 @@ const tryOpfsVfs = async function(sqlite3){
const db = new opfs.OpfsDb(dbFile,'ct');
log("db file:",db.filename);
await waitForRelinquish();
try{
if(opfs.entryExists(dbFile)){
let n = db.selectValue("select count(*) from sqlite_schema");
log("Persistent data found. sqlite_schema entry count =",n);
}
await waitForRelinquish();
db.transaction((db)=>{
db.exec({
sql:[
@ -63,7 +57,6 @@ const tryOpfsVfs = async function(sqlite3){
(performance.now() |0) / 4]
});
});
await waitForRelinquish();
log("count(*) from t =",db.selectValue("select count(*) from t"));
// Some sanity checks of the opfs utility functions...