Skip to content

Commit 7a6b141

Browse files
committed
Release 2.0.0
1 parent 7758ae8 commit 7a6b141

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

Sources/SystemExtensionKit/SystemExtensionRequest.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,22 @@ extension SystemExtensionRequest: OSSystemExtensionRequestDelegate {
7272
let existingBundleIdentifier = existing.bundleIdentifier
7373
let existingBundleVersion = existing.bundleVersion
7474
let existingBundleShortVersion = existing.bundleShortVersion
75+
let existingVersion = existingBundleShortVersion + "(\(existingBundleVersion))"
7576

7677
// ext
7778
let extBundleIdentifier = ext.bundleIdentifier
7879
let extBundleVersion = ext.bundleVersion
7980
let extBundleShortVersion = ext.bundleShortVersion
81+
let extVersion = extBundleShortVersion + "(\(extBundleVersion))"
8082

8183
if forceUpdate {
82-
requestUpdater?.systemExtensionRequest(self, updateProgress: .replacingExtension(existingVersion: existingBundleShortVersion, extVersion: extBundleShortVersion))
84+
updatingReplacingExtension(existingVersion: existingVersion, extVersion: extVersion)
8385
return .replace
8486
}
8587

8688
if #available(macOS 12.0, *) {
8789
if existing.isAwaitingUserApproval {
88-
requestUpdater?.systemExtensionRequest(self, updateProgress: .replacingExtension(existingVersion: existingBundleShortVersion, extVersion: extBundleShortVersion))
90+
updatingReplacingExtension(existingVersion: existingVersion, extVersion: extVersion)
8991
return .replace
9092
}
9193
}
@@ -94,11 +96,11 @@ extension SystemExtensionRequest: OSSystemExtensionRequestDelegate {
9496
existingBundleVersion == extBundleVersion,
9597
existingBundleShortVersion == extBundleShortVersion
9698
else {
97-
requestUpdater?.systemExtensionRequest(self, updateProgress: .replacingExtension(existingVersion: existingBundleShortVersion, extVersion: extBundleShortVersion))
99+
updatingReplacingExtension(existingVersion: existingVersion, extVersion: extVersion)
98100
return .replace
99101
}
100102

101-
requestUpdater?.systemExtensionRequest(self, updateProgress: .cancelExtension(existingVersion: existingBundleShortVersion, extVersion: extBundleShortVersion))
103+
updatingCancelExtension(existingVersion: existingVersion, extVersion: extVersion)
102104
return .cancel
103105
default:
104106
return .cancel
@@ -143,6 +145,18 @@ extension SystemExtensionRequest: OSSystemExtensionRequestDelegate {
143145
}
144146
}
145147

148+
// MARK: - SystemExtensionRequestUpdating callback
149+
150+
private extension SystemExtensionRequest {
151+
private func updatingReplacingExtension(existingVersion: String, extVersion: String) {
152+
requestUpdater?.systemExtensionRequest(self, updateProgress: .replacingExtension(existingVersion: existingVersion, extVersion: extVersion))
153+
}
154+
155+
private func updatingCancelExtension(existingVersion: String, extVersion: String) {
156+
requestUpdater?.systemExtensionRequest(self, updateProgress: .cancelExtension(existingVersion: existingVersion, extVersion: extVersion))
157+
}
158+
}
159+
146160
public extension SystemExtensionRequest {
147161
enum Action: CustomStringConvertible {
148162
case activate(forceUpdate: Bool)

0 commit comments

Comments
 (0)