]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add SAHPoolUtil.getFileNames() method, and tests for it, per [forum:a3da1e34d8|forum...
authorstephan <stephan@noemail.net>
Wed, 26 Jul 2023 11:11:39 +0000 (11:11 +0000)
committerstephan <stephan@noemail.net>
Wed, 26 Jul 2023 11:11:39 +0000 (11:11 +0000)
FossilOrigin-Name: 72dc3f8c3255186ec412412b685b0b51ddcd08240f2353ac742fc7da8c23568e

ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js
ext/wasm/tester1.c-pp.js
manifest
manifest.uuid

index 9bf1421a9f474520b767fa4cdab5773ae6d755f5..ee8d1a5d6856cd8055119db5e37aaf873fd4cf19 100644 (file)
@@ -501,6 +501,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
     /* Current number of in-use files from pool. */
     getFileCount(){return this.#mapFilenameToSAH.size}
 
+    /* Returns an array of the names of all
+       currently-opened client-specified filenames. */
+    getFileNames(){
+      const rc = [];
+      const iter = this.#mapFilenameToSAH.keys();
+      for(const n of iter) rc.push(n);
+      return rc;
+    }
+
 //    #createFileObject(sah,clientName,opaqueName){
 //      const f = Object.assign(Object.create(null),{
 //        clientName, opaqueName
@@ -901,6 +910,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
     getCapacity(){ return this.#p.getCapacity(this.#p) }
 
     getFileCount(){ return this.#p.getFileCount() }
+    getFileNames(){ return this.#p.getFileNames() }
 
     async reserveMinimumCapacity(min){
       const c = this.#p.getCapacity();
@@ -1059,6 +1069,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
      Returns the number of files from the pool currently allocated to
      slots. This is not the same as the files being "opened".
 
+     - array getFileNames()
+
+     Returns an array of the names of the files currently allocated to
+     slots. This list is the same length as getFileCount().
+
      - void importDb(name, byteArray)
 
      Imports the contents of an SQLite database, provided as a byte
index 905340b234ee94e01063908c04a39387a8b00d6e..db4b50f4b656de529e5f0bdbf7dbc9f9876342f5 100644 (file)
@@ -3072,10 +3072,23 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
         db = new u2.OpfsSAHPoolDb(dbName);
         T.assert(1 === u1.getFileCount());
         db.close();
-        T.assert(1 === u1.getFileCount())
+        const fileNames = u1.getFileNames();
+        T.assert(1 === fileNames.length)
+          .assert(dbName === fileNames[0])
+          .assert(1 === u1.getFileCount())
           .assert(true === u1.unlink(dbName))
           .assert(false === u1.unlink(dbName))
-          .assert(0 === u1.getFileCount());
+          .assert(0 === u1.getFileCount())
+          .assert(0 === u1.getFileNames().length);
+
+        // Demonstrate that two SAH pools can coexist so long as
+        // they have different names.
+        const conf2 = JSON.parse(JSON.stringify(sahPoolConfig));
+        conf2.name += '-test2';
+        const POther = await inst(conf2);
+        log("Installed second SAH instance as",conf2.name);
+        T.assert(0 === POther.getFileCount())
+          .assert(true === await POther.removeVfs());
         if(0){
            /* Enable this block to inspect vfs's contents via the dev
               console or OPFS Explorer browser extension.  The
@@ -3087,7 +3100,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
           .assert(!sqlite3.capi.sqlite3_vfs_find(sahPoolConfig.name));
 
         let cErr, u3;
-        const conf2 = JSON.parse(JSON.stringify(sahPoolConfig));
         conf2.$testThrowInInit = new Error("Testing throwing during init.");
         conf2.name = sahPoolConfig.name+'-err';
         const P3 = await inst(conf2).then(u=>u3 = u).catch((e)=>cErr=e);
index 5f921c0e86466d92a88b6a18f2566a5b197eb9d6..5f4f8afbf054e37ec75be5f5a5f7bfabe29169b6 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Reformulate\s[907dfc4a7aa1]\susing\sawk\sinstead\sof\ssed\sfor\sbetter\scross-platform\sportability.
-D 2023-07-26T07:57:55.835
+C Add\sSAHPoolUtil.getFileNames()\smethod,\sand\stests\sfor\sit,\sper\s[forum:a3da1e34d8|forum\sfeedback].\sAdd\sa\stest\sto\sdemonstrate\sthat\stwo\sSAH\spools\scan\scoexist\sso\slong\sas\sthey\shave\sdifferent\snames.
+D 2023-07-26T11:11:39.057
 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 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379
 F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25
-F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 7931b50b63246a3d6b46a4c703c28820aa10c5b1ae7c0718e1f58dae2cf6db85
+F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 44740935f6eeab3a0c6dc9f0ca93aebb6339f8d8365f03ea6d7808c134dbfe46
 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
@@ -549,7 +549,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
 F ext/wasm/test-opfs-vfs.js f09266873e1a34d9bdb6d3981ec8c9e382f31f215c9fd2f9016d2394b8ae9b7b
 F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c
 F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
-F ext/wasm/tester1.c-pp.js f835c9f703b562142f23a3607fa4a34cb6aece5fb5d674ea5bd7d37b0e47e104
+F ext/wasm/tester1.c-pp.js b9a493a764f2113f6a8205d4e5573a25731d6f965338005460920389ac0693e0
 F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a982deea6079efd98098d3e42fbcbc1
 F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@@ -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 54b3c43fdfdaca6b129a5f0ee93c34eb001663775d33c087066650f5e164d1c1
-R bd64b4635e08e21fec1b91b485560c00
+P 82ff7cc6a4b0331677be87bc069da414a56fd531bae402d0f0808b5d2b0d45da
+R 49d65d8d7213fb16653e94d68282a21d
 U stephan
-Z 9b053abd49b0547974c7dd9e0baf8df0
+Z ce157938736081078b3928b891966201
 # Remove this line to create a well-formed Fossil manifest.
index 9d9c089cd894fee51fe5515a8d690b55301ad9fa..f9d3b51fcc0a9acbc31ada4ca6416ea8eb151cf0 100644 (file)
@@ -1 +1 @@
-82ff7cc6a4b0331677be87bc069da414a56fd531bae402d0f0808b5d2b0d45da
\ No newline at end of file
+72dc3f8c3255186ec412412b685b0b51ddcd08240f2353ac742fc7da8c23568e
\ No newline at end of file