Skip to content

Commit 0944ab5

Browse files
committed
Fix runner crashes
1 parent 412d814 commit 0944ab5

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

ResticSchedulerKit/ResticRunner.swift

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
import Foundation
22

33
@objc public class BackupOptions: NSObject, NSSecureCoding {
4+
public enum CodingKeys: String, CodingKey {
5+
case logURL
6+
case summaryURL
7+
case arguments
8+
case includes
9+
case excludes
10+
case environment
11+
case beforeBackup
12+
case onSuccess
13+
case onFailure
14+
}
15+
416
public let logURL: URL
517
public let summaryURL: URL
618
public let arguments: [String]
@@ -26,27 +38,27 @@ import Foundation
2638
public static var supportsSecureCoding: Bool { true }
2739

2840
public func encode(with coder: NSCoder) {
29-
coder.encode(logURL, forKey: "logURL")
30-
coder.encode(summaryURL, forKey: "summaryURL")
31-
coder.encode(arguments, forKey: "arguments")
32-
coder.encode(includes, forKey: "includes")
33-
coder.encode(excludes, forKey: "excludes")
34-
coder.encode(environment, forKey: "environment")
35-
coder.encode(beforeBackup, forKey: "beforeBackup")
36-
coder.encode(onSuccess, forKey: "onSuccess")
37-
coder.encode(onFailure, forKey: "onFailure")
41+
coder.encode(logURL, forKey: CodingKeys.logURL.rawValue)
42+
coder.encode(summaryURL, forKey: CodingKeys.summaryURL.rawValue)
43+
coder.encode(arguments, forKey: CodingKeys.arguments.rawValue)
44+
coder.encode(includes, forKey: CodingKeys.includes.rawValue)
45+
coder.encode(excludes, forKey: CodingKeys.excludes.rawValue)
46+
coder.encode(environment, forKey: CodingKeys.environment.rawValue)
47+
coder.encode(beforeBackup, forKey: CodingKeys.beforeBackup.rawValue)
48+
coder.encode(onSuccess, forKey: CodingKeys.onSuccess.rawValue)
49+
coder.encode(onFailure, forKey: CodingKeys.onFailure.rawValue)
3850
}
3951

4052
public required init?(coder: NSCoder) {
41-
logURL = coder.decodeObject(of: NSURL.self, forKey: "logURL")! as URL
42-
summaryURL = coder.decodeObject(of: NSURL.self, forKey: "summaryURL")! as URL
43-
arguments = coder.decodeArrayOfObjects(ofClass: NSString.self, forKey: "arguments")! as [String]
44-
includes = coder.decodeArrayOfObjects(ofClass: NSString.self, forKey: "includes")! as [String]
45-
excludes = coder.decodeArrayOfObjects(ofClass: NSString.self, forKey: "excludes")! as [String]
46-
environment = coder.decodeDictionary(withKeyClass: NSString.self, objectClass: NSString.self, forKey: "environment")! as [String: String]
47-
beforeBackup = coder.decodeObject(of: NSString.self, forKey: "beforeBackup")! as String
48-
onSuccess = coder.decodeObject(of: NSString.self, forKey: "onSuccess")! as String
49-
onFailure = coder.decodeObject(of: NSString.self, forKey: "onFailure")! as String
53+
logURL = coder.decodeObject(of: NSURL.self, forKey: CodingKeys.logURL.rawValue)! as URL
54+
summaryURL = coder.decodeObject(of: NSURL.self, forKey: CodingKeys.summaryURL.rawValue)! as URL
55+
arguments = coder.decodeArrayOfObjects(ofClass: NSString.self, forKey: CodingKeys.arguments.rawValue)! as [String]
56+
includes = coder.decodeArrayOfObjects(ofClass: NSString.self, forKey: CodingKeys.includes.rawValue)! as [String]
57+
excludes = coder.decodeArrayOfObjects(ofClass: NSString.self, forKey: CodingKeys.excludes.rawValue)! as [String]
58+
environment = coder.decodeDictionary(withKeyClass: NSString.self, objectClass: NSString.self, forKey: CodingKeys.environment.rawValue)! as [String: String]
59+
beforeBackup = coder.decodeObject(of: NSString.self, forKey: CodingKeys.beforeBackup.rawValue) as? String
60+
onSuccess = coder.decodeObject(of: NSString.self, forKey: CodingKeys.onSuccess.rawValue) as? String
61+
onFailure = coder.decodeObject(of: NSString.self, forKey: CodingKeys.onFailure.rawValue) as? String
5062
}
5163
}
5264

ResticSchedulerKit/Utilities.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public func withCallingReplyOnce<Result, Error>(_ reply: @escaping (Result, Erro
5252
return
5353
}
5454

55-
Logger.function().warning("Ignored subsequent call at \(function)")
55+
Logger.function().warning("Ignored subsequent call at \(function, privacy: .public)")
5656
}
5757
}
5858

@@ -64,7 +64,7 @@ public func withCallingReplyOnce<Error>(_ reply: @escaping (Error) -> Void, func
6464
return
6565
}
6666

67-
Logger.function().warning("Ignored subsequent call at \(function)")
67+
Logger.function().warning("Ignored subsequent call at \(function, privacy: .public)")
6868
}
6969
}
7070

0 commit comments

Comments
 (0)