diff options
Diffstat (limited to 'ext/wasm')
-rw-r--r-- | ext/wasm/api/sqlite3-vfs-opfs-sahpool.js | 13 | ||||
-rw-r--r-- | ext/wasm/tester1.c-pp.js | 16 |
2 files changed, 19 insertions, 10 deletions
diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js index fc088c419..7547c01a8 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js @@ -160,12 +160,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } return this.getCapacity(); } - /** - Removes n entries from the pool's current capacity - if possible. It can only remove currently-unallocated - files. Returns a Promise resolving to the number of - removed files. - */ async reduceCapacity(n){ let nRm = 0; for(const ah of Array.from(this.availableSAH)){ @@ -424,7 +418,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ getCapacity(){ return this.#p.getCapacity(this.#p); } - getActiveFileCount(){ + getFileCount(){ return this.#p.getFileCount(); } async reserveMinimumCapacity(min){ @@ -610,9 +604,10 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ in the SAH pool. The default capacity is only large enough for one or two databases and their associated temp files. - - number getActiveFileCount() + - number getFileCount() - Returns the number of files from the pool currently in use. + Returns the number of files from the pool currently allocated to + slots. This is not the same as the files being "opened". - void importDb(name, byteArray) diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index e63d8440c..27a8118e8 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2784,18 +2784,32 @@ globalThis.sqlite3InitModule = sqlite3InitModule; can have more than the initial capacity on the next run. */) .assert(u1.getCapacity() + 2 === (await u2.addCapacity(2))) + .assert(2 === (await u2.reduceCapacity(2))) .assert(sqlite3.oo1.OpfsSAHPool.default instanceof Function) .assert(sqlite3.oo1.OpfsSAHPool.default === sqlite3.oo1.OpfsSAHPool[sahPoolConfig.name]) .assert(sqlite3.capi.sqlite3_js_vfs_list().indexOf(sahPoolConfig.name) >= 0); - const db = new sqlite3.oo1.OpfsSAHPool.default("foo.db"); + T.assert(0 === u1.getFileCount()); + const DbCtor = sqlite3.oo1.OpfsSAHPool.default; + const dbName = '/foo.db'; + let db = new DbCtor(dbName); + T.assert(1 === u1.getFileCount()); db.exec([ 'create table t(a);', 'insert into t(a) values(1),(2),(3)' ]); + T.assert(1 === u1.getFileCount()); T.assert(3 === db.selectValue('select count(*) from t')); db.close(); + T.assert(1 === u1.getFileCount()); + db = new DbCtor(dbName); + T.assert(1 === u1.getFileCount()); + db.close(); + T.assert(1 === u1.getFileCount()) + .assert(true === u1.unlink(dbName)) + .assert(false === u1.unlink(dbName)) + .assert(0 === u1.getFileCount()); T.assert(true === await u2.removeVfs()) .assert(false === await u1.removeVfs()) |