taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit be6609574133c8cacec36480ff2f67adad08357c
parent f11973203ed96c7dd17653fc513d5769e22cc3b3
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 31 Aug 2026 19:47:13 +0200

sqlite backup

Diffstat:
MTalerWallet1/Model/WalletModel.swift | 9+++++----
MTalerWallet1/Views/Settings/BackupView.swift | 12++++++++----
2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift @@ -588,14 +588,15 @@ extension WalletModel { // MARK: - fileprivate struct ExportDbToFile: WalletBackendFormattedRequest { var operation: String { "exportDbToFile" } - func args() -> Args { Args(directory: directory, stem: stem, forceFormat: "json") } + func args() -> Args { Args(directory: directory, stem: stem, forceFormat: asJSON ? "json" : nil) } var directory: String var stem: String + var asJSON: Bool struct Args: Encodable { var directory: String var stem: String - var forceFormat: String + var forceFormat: String? } struct Response: Decodable, Sendable { // path of the copied DB var path: String @@ -629,11 +630,11 @@ fileprivate struct GetPerformanceStats: WalletBackendFormattedRequest { extension WalletModel { /// export, import DB, get diagnostics - nonisolated func exportDbToFile(stem: String, viewHandles: Bool = false) + nonisolated func exportDbToFile(stem: String, asJSON: Bool = true, viewHandles: Bool = false) async throws -> String? { if let docDirUrl = URL.docDirUrl { let dbPath = docDirUrl.path(withSlash: false) - let request = ExportDbToFile(directory: dbPath, stem: stem) + let request = ExportDbToFile(directory: dbPath, stem: stem, asJSON: asJSON) print(dbPath, stem) let response = try await sendRequest(request, viewHandles: viewHandles) return response.path diff --git a/TalerWallet1/Views/Settings/BackupView.swift b/TalerWallet1/Views/Settings/BackupView.swift @@ -37,12 +37,12 @@ struct BackupView: View { } } - private func createBackup() { + private func createBackup(asJSON: Bool) { created = true Task { let dateString = Date().iso let stem = String(BACKUP + dateString) - if let backupFile = try? await model.exportDbToFile(stem: stem) { + if let backupFile = try? await model.exportDbToFile(stem: stem, asJSON: asJSON) { filename = backupFile await viewDidLoad() } @@ -92,7 +92,8 @@ struct BackupView: View { let _ = Self._printChanges() let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let buttonTitle = String(localized: "Create Backup", comment: "button") + let buttonTitle1 = String(localized: "Create JSON backup", comment: "button") + let buttonTitle2 = String(localized: "Create sqlite backup", comment: "button") let backupHint = Text("Tap 'Create Backup' to make a copy of your digital money. Connect your iPhone to a computer, then use the Files dialog and copy that backup to the computer.") @@ -104,7 +105,10 @@ struct BackupView: View { Section { backupHint .listRowSeparator(.hidden) - FeedbackButton(buttonTitle, disabled: created) { createBackup() } + FeedbackButton(buttonTitle1, disabled: created) { createBackup(asJSON: true) } + .padding(.horizontal) + .listRowSeparator(.hidden) + FeedbackButton(buttonTitle2, disabled: created) { createBackup(asJSON: false) } .padding(.horizontal) .listRowSeparator(.hidden) restoreHint