xClose: function(pFile){
const pool = getPoolForPFile(pFile);
pool.storeErr();
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
if(file) {
try{
pool.log(`xClose ${file.path}`);
- pool.mapSFileToOFile(pFile, false);
+ pool.mapS3FileToOFile(pFile, false);
file.sah.flush();
if(file.flags & capi.SQLITE_OPEN_DELETEONCLOSE){
pool.deletePath(file.path);
xFileSize: function(pFile,pSz64){
const pool = getPoolForPFile(pFile);
pool.log(`xFileSize`);
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
const size = file.sah.getSize() - HEADER_OFFSET_DATA;
//log(`xFileSize ${file.path} ${size}`);
wasm.poke64(pSz64, BigInt(size));
const pool = getPoolForPFile(pFile);
pool.log(`xLock ${lockType}`);
pool.storeErr();
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
file.lockType = lockType;
return 0;
},
xRead: function(pFile,pDest,n,offset64){
const pool = getPoolForPFile(pFile);
pool.storeErr();
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
pool.log(`xRead ${file.path} ${n} @ ${offset64}`);
try {
const nRead = file.sah.read(
const pool = getPoolForPFile(pFile);
pool.log(`xSync ${flags}`);
pool.storeErr();
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
//log(`xSync ${file.path} ${flags}`);
try{
file.sah.flush();
const pool = getPoolForPFile(pFile);
pool.log(`xTruncate ${sz64}`);
pool.storeErr();
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
//log(`xTruncate ${file.path} ${iSize}`);
try{
file.sah.truncate(HEADER_OFFSET_DATA + Number(sz64));
xUnlock: function(pFile,lockType){
const pool = getPoolForPFile(pFile);
pool.log('xUnlock');
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
file.lockType = lockType;
return 0;
},
xWrite: function(pFile,pSrc,n,offset64){
const pool = getPoolForPFile(pFile);
pool.storeErr();
- const file = pool.getOFileForSFile(pFile);
+ const file = pool.getOFileForS3File(pFile);
pool.log(`xWrite ${file.path} ${n} ${offset64}`);
try{
const nBytes = file.sah.write(
// Subsequent I/O methods are only passed the sqlite3_file
// pointer, so map the relevant info we need to that pointer.
const file = {path, flags, sah};
- pool.mapSFileToOFile(pFile, file);
+ pool.mapS3FileToOFile(pFile, file);
file.lockType = capi.SQLITE_LOCK_NONE;
const sq3File = new capi.sqlite3_file(pFile);
sq3File.$pMethods = opfsIoMethods.pointer;
Creates and initializes an sqlite3_vfs instance for an
OpfsSAHPool. The argument is the VFS's name (JS string).
+ Throws if the VFS name is already registered or if something
+ goes terribly wrong via sqlite3.vfs.installVfs().
+
Maintenance reminder: the only detail about the returned object
which is specific to any given OpfsSAHPool instance is the $zName
member. All other state is identical.
*/
const createOpfsVfs = function(vfsName){
+ if( sqlite3.capi.sqlite3_vfs_find(vfsName)){
+ toss3("VFS name is already registered:", vfsName);
+ }
const opfsVfs = new capi.sqlite3_vfs();
/* We fetch the default VFS so that we can inherit some
methods from it. */
/* Set of currently-unused SAHs. */
#availableSAH = new Set();
/* Maps (sqlite3_file*) to xOpen's file objects. */
- #mapSqlite3FileToFile = new Map();
+ #mapS3FileToOFile_ = new Map();
+
+ /* Maps SAH to an abstract File Object which contains
+ various metadata about that handle. */
+ //#mapSAHToMeta = new Map();
/** Buffer used by [sg]etAssociatedPath(). */
#apBody = new Uint8Array(HEADER_CORPUS_SIZE);
constructor(options = Object.create(null)){
this.#verbosity = options.verbosity ?? optionDefaults.verbosity;
this.vfsName = options.name || optionDefaults.name;
- if( sqlite3.capi.sqlite3_vfs_find(this.vfsName)){
- toss3("VFS name is already registered:", this.vfsName);
- }
this.#cVfs = createOpfsVfs(this.vfsName);
setPoolForVfs(this.#cVfs.pointer, this);
this.vfsDir = options.directory || ("."+this.vfsName);
/* Current number of in-use files from pool. */
getFileCount(){return this.#mapFilenameToSAH.size}
+// #createFileObject(sah,clientName,opaqueName){
+// const f = Object.assign(Object.create(null),{
+// clientName, opaqueName
+// });
+// this.#mapSAHToMeta.set(sah, f);
+// return f;
+// }
+// #unmapFileObject(sah){
+// this.#mapSAHToMeta.delete(sah);
+// }
+
/**
Adds n files to the pool's capacity. This change is
persistent across settings. Returns a Promise which resolves
const ah = await h.createSyncAccessHandle();
this.#mapSAHToName.set(ah,name);
this.setAssociatedPath(ah, '', 0);
+ //this.#createFileObject(ah,undefined,name);
}
return this.getCapacity();
}
break;
}
const name = this.#mapSAHToName.get(ah);
+ //this.#unmapFileObject(ah);
ah.close();
await this.#dhOpaque.removeEntry(name);
this.#mapSAHToName.delete(ah);
Given an (sqlite3_file*), returns the mapped
xOpen file object.
*/
- getOFileForSFile(ptr){
- return this.#mapSqlite3FileToFile.get(ptr);
+ getOFileForS3File(pFile){
+ return this.#mapS3FileToOFile_.get(pFile);
}
/**
Maps or unmaps (if file is falsy) the given (sqlite3_file*)
to an xOpen file object and to this pool object.
*/
- mapSFileToOFile(pFile,file){
+ mapS3FileToOFile(pFile,file){
if(file){
- this.#mapSqlite3FileToFile.set(pFile, file);
+ this.#mapS3FileToOFile_.set(pFile, file);
setPoolForPFile(pFile, this);
}else{
- this.#mapSqlite3FileToFile.delete(pFile);
+ this.#mapS3FileToOFile_.delete(pFile);
setPoolForPFile(pFile, false);
}
}
-C Internal\scleanups\sin\sthe\sasync\spart\sof\sthe\sJS\slibrary\sbootstrap\sphase.
-D 2023-07-21T09:10:42.614
+C Minor\sinternal\scleanups\sin\sthe\sopfs-sahpool\sVFS.
+D 2023-07-21T10:51:35.142
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379
F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25
-F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js d9abf3cde87aea55ea901e80f70e55b36055e8e5120ed47321af35afb9facdaa
+F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js bb99a931388966a032f635a0cc9cd72685e067f21b95b2a58a660c055020b739
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e7a690e0e78ff4d563f2eca468f91db69f001ff4b79c6d2304cbb6f62dca437d
F ext/wasm/api/sqlite3-wasm.c 8867f1d41c112fb4a2cfe22ff224eccaf309fcdea266cee0ec554f85db72ef0f
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 21a2ca9fc46bf746874579897872e2a45cb07f278abb670dd22b122f7d6a9a6c
-R 29a8f4f8ea37e0c15f874df4805828de
+P b6d57ab63793241a500ea527c5b3216c54b3ff1972d3adbbf42a9a53bfec0aa1
+R 04390a13b454e3d10f0ad00241913292
U stephan
-Z 8b913efdb9ce5e9239da5b5f12183785
+Z 911ec9b641009d60f6f5bfe849c03052
# Remove this line to create a well-formed Fossil manifest.