gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-ios] 12/19: CachePath for data not to be backed up


From: gnunet
Subject: [taler-taler-ios] 12/19: CachePath for data not to be backed up
Date: Sat, 02 Sep 2023 22:01:13 +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 459811ce8e5e04a39ca9ca0acc8c0bed39bbf613
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Aug 31 21:07:26 2023 +0200

    CachePath for data not to be backed up
---
 TalerWallet1/Model/WalletModel.swift | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/TalerWallet1/Model/WalletModel.swift 
b/TalerWallet1/Model/WalletModel.swift
index 47c6c33..eea87e4 100644
--- a/TalerWallet1/Model/WalletModel.swift
+++ b/TalerWallet1/Model/WalletModel.swift
@@ -110,16 +110,36 @@ extension WalletModel {
     }
 
     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(sqlite3 ? "sqlite3" : "json")
-            let docPath = storageDir.path
+        if let documentsUrl = FileManager.default.urls(for: 
.documentDirectory, in: .userDomainMask).first {
+            let documentUrl = documentsUrl.appendingPathComponent(DATABASE, 
isDirectory: false)
+                                          .appendingPathExtension(sqlite3 ? 
"sqlite3" : "json")
+            let docPath = documentUrl.path
             logger.debug("\(docPath)")
             return docPath
         } else {    // should never happen
-            logger.error("documentURLs empty")
+            logger.error("No documentDirectory")
+            throw WalletBackendError.initializationError
+        }
+    }
+
+    private func cachePath () throws -> String {
+        let fileManager = FileManager.default
+        if let cachesURL = fileManager.urls(for: .cachesDirectory, in: 
.userDomainMask).first {
+            let cacheURL = cachesURL.appendingPathComponent("cache.json")
+            let cachePath = cacheURL.path
+            logger.debug("\(cachePath)")
+
+            if !fileManager.fileExists(atPath: cachePath) {
+                let contents = Data()       /// Initialize an empty `Data`.
+                fileManager.createFile(atPath: cachePath, contents: contents)
+                print("File \(cachePath) created")
+            } else {
+                print("File \(cachePath) already exists")
+            }
+
+            return cachePath
+        } else {    // should never happen
+            logger.error("No cachesDirectory")
             throw WalletBackendError.initializationError
         }
     }

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