[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.
- [taler-taler-ios] 03/19: Use sqlite3, (continued)
- [taler-taler-ios] 03/19: Use sqlite3, gnunet, 2023/09/02
- [taler-taler-ios] 04/19: Rename, gnunet, 2023/09/02
- [taler-taler-ios] 02/19: Changed "Invoice" to "Request" (private mode - "Invoice" will be used in business mode post 1.0), roundedBorder for input fields, gnunet, 2023/09/02
- [taler-taler-ios] 08/19: IntegrationTest on test, gnunet, 2023/09/02
- [taler-taler-ios] 13/19: ScopedCurrencyInfo, SuperScriptDigit, gnunet, 2023/09/02
- [taler-taler-ios] 05/19: Comment, gnunet, 2023/09/02
- [taler-taler-ios] 18/19: Nunito Font, gnunet, 2023/09/02
- [taler-taler-ios] 16/19: Rename, fix, gnunet, 2023/09/02
- [taler-taler-ios] 14/19: CurrencyFormatter, gnunet, 2023/09/02
- [taler-taler-ios] 09/19: Accessibility String for Payment Sounds, gnunet, 2023/09/02
- [taler-taler-ios] 12/19: CachePath for data not to be backed up,
gnunet <=
- [taler-taler-ios] 11/19: Settings: Font: AtkinsonHyperlegible, gnunet, 2023/09/02
- [taler-taler-ios] 19/19: Font Settings, gnunet, 2023/09/02
- [taler-taler-ios] 10/19: Comment, gnunet, 2023/09/02
- [taler-taler-ios] 06/19: Rename, gnunet, 2023/09/02
- [taler-taler-ios] 15/19: group, gnunet, 2023/09/02
- [taler-taler-ios] 07/19: secret-token:secret, gnunet, 2023/09/02
- [taler-taler-ios] 17/19: GNU Taler, Taler Wallet, gnunet, 2023/09/02