Exclude security.json from iCloud backup
@@ -96,9 +96,20 @@ class AppSecurity {
///
private func writeToDisk(securityFile: SecurityFile) throws {
+ var url = self.securityJsonUrl
+
let jsonData = try JSONEncoder().encode(securityFile)
+ try jsonData.write(to: url, options: [.atomic])
+
+ do {
+ var resourceValues = URLResourceValues()
+ resourceValues.isExcludedFromBackup = true
+ try url.setResourceValues(resourceValues)
- try jsonData.write(to: self.securityJsonUrl, options: [.atomic])
+ } catch {
+ // Don't throw from this error as it's an optimization
+ log.error("Error excluding \(url.lastPathComponent) from backup \(String(describing: error))")
+ }
}
private func validateParameter(mnemonics: [String]) -> Data {
