gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 03/19: Use sqlite3


From: gnunet
Subject: [taler-taler-ios] 03/19: Use sqlite3
Date: Sat, 02 Sep 2023 22:01:04 +0200

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

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit 6c25aed49233d09fb701d661417381815596388b
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Aug 22 17:12:33 2023 +0200

    Use sqlite3
---
 TalerWallet1/Controllers/Controller.swift      | 4 ++--
 TalerWallet1/Controllers/TalerWallet1App.swift | 3 ++-
 TalerWallet1/Model/WalletModel.swift           | 8 ++++----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/TalerWallet1/Controllers/Controller.swift 
b/TalerWallet1/Controllers/Controller.swift
index d2d3c30..e02f0a3 100644
--- a/TalerWallet1/Controllers/Controller.swift
+++ b/TalerWallet1/Controllers/Controller.swift
@@ -43,12 +43,12 @@ class Controller: ObservableObject {
     }
 
     @MainActor
-    func initWalletCore(_ model: WalletModel)
+    func initWalletCore(_ model: WalletModel, sqlite3: Bool)
       async throws {
         if backendState == .instantiated {
             backendState = .initing
             do {
-                let versionInfo = try await model.initWalletCoreT()
+                let versionInfo = try await model.initWalletCoreT(sqlite3: 
sqlite3)
                 WalletCore.shared.versionInfo = versionInfo
                 backendState = .ready                       // dismiss the 
launch animation
             } catch {       // rethrows
diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift 
b/TalerWallet1/Controllers/TalerWallet1App.swift
index bff3e7a..d46b6d3 100644
--- a/TalerWallet1/Controllers/TalerWallet1App.swift
+++ b/TalerWallet1/Controllers/TalerWallet1App.swift
@@ -27,6 +27,7 @@ struct TalerWallet1App: App {
     private let model = WalletModel.shared
     private let debugViewC = DebugViewC.shared
     let logger = Logger (subsystem: "net.taler.gnu", category: "Main App")
+    let sqlite3 = true                                                         
 // true = SQLITE3, false = JSON
 
     func scheduleAppRefresh() {
         let request = BGAppRefreshTaskRequest(identifier: 
"net.taler.gnu.refresh")
@@ -45,7 +46,7 @@ struct TalerWallet1App: App {
                     /// we handle them in .onOpenURL in MainView.swift
                 .handlesExternalEvents(preferring: ["*"], allowing: ["*"])
                 .task {
-                    try! await controller.initWalletCore(model)     // will 
(and should) crash on failure
+                    try! await controller.initWalletCore(model, sqlite3: 
sqlite3)     // will (and should) crash on failure
                 }
                 .onReceive(NotificationCenter.default.publisher(for: 
UIApplication.didBecomeActiveNotification, object: nil)) { _ in
                     logger.log("❗️App Did Become Active")
diff --git a/TalerWallet1/Model/WalletModel.swift 
b/TalerWallet1/Model/WalletModel.swift
index d5dc714..47c6c33 100644
--- a/TalerWallet1/Model/WalletModel.swift
+++ b/TalerWallet1/Model/WalletModel.swift
@@ -101,20 +101,20 @@ fileprivate struct InitRequest: 
WalletBackendFormattedRequest {
 
 extension WalletModel {
     /// initalize Wallet-Core. Will do networking
-    func initWalletCoreT() async throws -> VersionInfo {
+    func initWalletCoreT(sqlite3: Bool) async throws -> VersionInfo {
                     // T for any Thread
-        let docPath = try docPath()
+        let docPath = try docPath(sqlite3: sqlite3)
         let request = InitRequest(persistentStoragePath: docPath)
         let response = try await sendRequest(request, 0)    // no Delay
         return response.versionInfo
     }
 
-    private func docPath () throws -> String {
+    private func docPath (sqlite3: Bool) throws -> String {
         let documentUrls = FileManager.default.urls(for: .documentDirectory, 
in: .userDomainMask)
         if (documentUrls.count > 0) {
             var storageDir = documentUrls[0]
             storageDir.appendPathComponent(DATABASE, isDirectory: false)
-            storageDir.appendPathExtension("json")
+            storageDir.appendPathExtension(sqlite3 ? "sqlite3" : "json")
             let docPath = storageDir.path
             logger.debug("\(docPath)")
             return docPath

-- 
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]