@@ -28,32 +28,44 @@ public struct DownloadReference: RenderReference, URLReference {
28
28
public var url : URL
29
29
30
30
/// The SHA512 hash value for the resource.
31
- public var sha512Checksum : String ?
31
+ public var checksum : String ?
32
+
33
+ @available ( * , deprecated, renamed: " checksum " )
34
+ public var sha512Checksum : String {
35
+ get {
36
+ return checksum ?? " "
37
+ }
38
+ set {
39
+ if newValue. isEmpty {
40
+ self . checksum = nil
41
+ } else {
42
+ self . checksum = newValue
43
+ }
44
+ }
45
+ }
32
46
33
47
/// Creates a new reference to a downloadable resource.
34
48
///
35
49
/// - Parameters:
36
50
/// - identifier: An identifier for the resource's reference.
37
51
/// - url: The path to the resource.
38
52
/// - sha512Checksum: The SHA512 hash value for the resource.
39
- public init ( identifier: RenderReferenceIdentifier , renderURL url: URL , sha512Checksum : String ? ) {
53
+ public init ( identifier: RenderReferenceIdentifier , renderURL url: URL , checksum : String ? ) {
40
54
self . identifier = identifier
41
55
self . url = url
42
- self . sha512Checksum = sha512Checksum
56
+ self . checksum = checksum
43
57
}
44
-
45
- enum CodingKeys : String , CodingKey {
46
- case type
47
- case identifier
48
- case url
49
- case sha512Checksum = " checksum "
58
+
59
+ @available ( * , deprecated, message: " Use 'init(identifier:renderURL:checksum:)' instead " )
60
+ public init ( identifier: RenderReferenceIdentifier , renderURL url: URL , sha512Checksum: String ) {
61
+ self . init ( identifier: identifier, renderURL: url, checksum: sha512Checksum)
50
62
}
51
63
52
64
public func encode( to encoder: Encoder ) throws {
53
65
var container = encoder. container ( keyedBy: CodingKeys . self)
54
66
try container. encode ( type. rawValue, forKey: . type)
55
67
try container. encode ( identifier, forKey: . identifier)
56
- try container. encodeIfPresent ( sha512Checksum , forKey: . sha512Checksum )
68
+ try container. encodeIfPresent ( checksum , forKey: . checksum )
57
69
58
70
// Render URL
59
71
try container. encode ( renderURL ( for: url) , forKey: . url)
0 commit comments