gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: qjs: allow directory as persi


From: gnunet
Subject: [taler-wallet-core] branch master updated: qjs: allow directory as persistentStoragePath
Date: Tue, 05 Nov 2024 11:55:27 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new c6f1a4b1d qjs: allow directory as persistentStoragePath
c6f1a4b1d is described below

commit c6f1a4b1d884171a109561a6dbd425a7fe537f79
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Nov 5 11:55:16 2024 +0100

    qjs: allow directory as persistentStoragePath
---
 packages/taler-wallet-embedded/src/wallet-qjs.ts | 37 ++++++++++++++++++++----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts 
b/packages/taler-wallet-embedded/src/wallet-qjs.ts
index 2780a3cab..40e3cb1c1 100644
--- a/packages/taler-wallet-embedded/src/wallet-qjs.ts
+++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts
@@ -49,7 +49,7 @@ import {
   testWithFdold,
   testWithGv,
   testWithLocal,
-} from './wallet-qjs-tests.js';
+} from "./wallet-qjs-tests.js";
 
 setGlobalLogLevelFromString("trace");
 
@@ -88,6 +88,28 @@ class NativeWalletMessageHandler {
 
     switch (operation) {
       case "init": {
+        // Allow specifying a directory as the storage path.
+        // In that case, we pick the filename and use the sqlite3
+        // backend.
+        //
+        // We still allow specifying a filename for backwards
+        // compatibility and control over the exact file.
+        //
+        // Specifying a directory allows us to automatically
+        // migrate to a new DB file in the future.
+        const p = args.args.persistentStoragePath;
+        let persistentStoragePath: string | undefined;
+        if (p != null) {
+          if (typeof p !== "string") {
+            throw Error("persistentStoragePath must be a string");
+          }
+          if (p.endsWith("/")) {
+            persistentStoragePath = `${p}talerwalletdb-v30.sqlite3`;
+          } else {
+            persistentStoragePath = p;
+          }
+        }
+
         const wR = await createNativeWalletHost2({
           notifyHandler: async (notification: WalletNotification) => {
             sendNativeMessage({ type: "notification", payload: notification });
@@ -106,11 +128,16 @@ class NativeWalletMessageHandler {
           enableNativeLogging();
         }
 
-        const resp = await wR.wallet.handleCoreApiRequest("initWallet", 
"native-init", {
-          config: args.config ?? {},
-        });
+        const resp = await wR.wallet.handleCoreApiRequest(
+          "initWallet",
+          "native-init",
+          {
+            config: args.config ?? {},
+          },
+        );
 
-        let initResponse: any = resp.type == "response" ? resp.result : 
resp.error;
+        let initResponse: any =
+          resp.type == "response" ? resp.result : resp.error;
 
         this.wp.resolve(wR.wallet);
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]