@@ -625,10 +625,77 @@ public struct SUAppcastItem: Sendable, Equatable {
625625 self . date = nil
626626 }
627627
628- self . installationType = " "
629- self . deltaUpdates = [ String: SUAppcastItem] ( )
630- self . deltaFromSparkleLocales = [ " en " ]
631- self . deltaFromSparkleExecutableSize = 0
628+ self . installationType = enclosure ? [ SUAppcastAttribute . InstallationType] ?? " "
629+
630+ var deltaUpdates : [ String : SUAppcastItem ] = [ : ]
631+ if let deltaEnclosures = dict [ SUAppcastElement . Deltas] as? [ SUAppcast . AttributesDictionary ] {
632+ for deltaEnclosure in deltaEnclosures {
633+ guard let deltaFromVersion = deltaEnclosure [ SUAppcastAttribute . DeltaFrom] , !deltaFromVersion. isEmpty else {
634+ continue
635+ }
636+
637+ var deltaItemDictionary = SUAppcastItemProperties ( )
638+ deltaItemDictionary [ SUAppcastElement . Version] = newVersion
639+
640+ var mergedEnclosure = deltaEnclosure
641+ if let osType = enclosure ? [ SUAppcastAttribute . OsType] , mergedEnclosure [ SUAppcastAttribute . OsType] == nil {
642+ mergedEnclosure [ SUAppcastAttribute . OsType] = osType
643+ }
644+ deltaItemDictionary [ SURSSElement . Enclosure] = mergedEnclosure
645+
646+ // Inherit state-affecting properties from parent item
647+ if let link = dict [ SURSSElement . Link] {
648+ deltaItemDictionary [ SURSSElement . Link] = link
649+ }
650+ if let informationalUpdate = dict [ SUAppcastElement . InformationalUpdate] {
651+ deltaItemDictionary [ SUAppcastElement . InformationalUpdate] = informationalUpdate
652+ }
653+ if let minimumSystemVersion = dict [ SUAppcastElement . MinimumSystemVersion] {
654+ deltaItemDictionary [ SUAppcastElement . MinimumSystemVersion] = minimumSystemVersion
655+ }
656+ if let maximumSystemVersion = dict [ SUAppcastElement . MaximumSystemVersion] {
657+ deltaItemDictionary [ SUAppcastElement . MaximumSystemVersion] = maximumSystemVersion
658+ }
659+ if let minimumAutoupdateVersion = dict [ SUAppcastElement . MinimumAutoupdateVersion] {
660+ deltaItemDictionary [ SUAppcastElement . MinimumAutoupdateVersion] = minimumAutoupdateVersion
661+ }
662+ if let ignoreSkippedUpgradesBelowVersion = dict [ SUAppcastElement . IgnoreSkippedUpgradesBelowVersion] {
663+ deltaItemDictionary [ SUAppcastElement . IgnoreSkippedUpgradesBelowVersion] = ignoreSkippedUpgradesBelowVersion
664+ }
665+ if let channel = dict [ SUAppcastElement . Channel] {
666+ deltaItemDictionary [ SUAppcastElement . Channel] = channel
667+ }
668+ if let tags = dict [ SUAppcastElement . Tags] {
669+ deltaItemDictionary [ SUAppcastElement . Tags] = tags
670+ }
671+ if let criticalUpdate = dict [ SUAppcastElement . CriticalUpdate] {
672+ deltaItemDictionary [ SUAppcastElement . CriticalUpdate] = criticalUpdate
673+ }
674+ if let shortVersionString = dict [ SUAppcastElement . ShortVersionString] {
675+ deltaItemDictionary [ SUAppcastElement . ShortVersionString] = shortVersionString
676+ }
677+
678+ do {
679+ let deltaItem = try SUAppcastItem ( dictionary: deltaItemDictionary, relativeTo: appcastURL, stateResolver: stateResolver, resolvedState: nil )
680+ deltaUpdates [ deltaFromVersion] = deltaItem
681+ } catch {
682+ continue
683+ }
684+ }
685+ }
686+ self . deltaUpdates = deltaUpdates
687+
688+ self . deltaFromSparkleExecutableSize = enclosure ? [ SUAppcastAttribute . DeltaFromSparkleExecutableSize] . flatMap ( Int . init)
689+ if let deltaLocalesString = enclosure ? [ SUAppcastAttribute . DeltaFromSparkleLocales] {
690+ let locales = deltaLocalesString
691+ . split ( separator: " , " )
692+ . map { String ( $0) . trimmingCharacters ( in: . whitespacesAndNewlines) }
693+ . filter { !$0. isEmpty }
694+
695+ self . deltaFromSparkleLocales = Set ( locales. prefix ( Self . DELTA_EXPECTED_LOCALES_LIMIT) )
696+ } else {
697+ self . deltaFromSparkleLocales = nil
698+ }
632699 }
633700
634701 private static func parseChannel( _ dict: SUAppcastItemProperties ) -> String ? {
0 commit comments