Skip to content

Commit

Permalink
Exclude transaction log from backups
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej Mihajlov committed Oct 27, 2023
1 parent 5aa67bc commit c0da624
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ios/MullvadVPN/StorePaymentManager/StoreTransactionLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,25 @@ final class StoreTransactionLog {
}

/// Write a list of transaction identifiers on disk.
///
/// Transaction identifiers are stored as one per line.
/// Always ensures to exclude the transaction log file from backups after writing contents on disk.
/// - Parameter serializedString: serialized transaction log
private func persistInner(serializedString: String) throws {
try serializedString.write(to: fileURL, atomically: true, encoding: .utf8)
excludeFromBackups()
}

/// Exclude transaction log file from backups.
private func excludeFromBackups() {
do {
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true

var mutableFileURL = fileURL
try mutableFileURL.setResourceValues(resourceValues)
} catch {
logger.error(error: error, message: "Failed to exclude transaction log from backups.")
}
}
}

0 comments on commit c0da624

Please sign in to comment.