Improve update UI error details
This commit is contained in:
parent
17a3e2033f
commit
0441efc675
18 changed files with 915 additions and 82 deletions
|
|
@ -3,7 +3,11 @@ import Cocoa
|
|||
|
||||
extension UpdateDriver: SPUUpdaterDelegate {
|
||||
func feedURLString(for updater: SPUUpdater) -> String? {
|
||||
Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String
|
||||
let infoURL = Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String
|
||||
let fallback = "https://github.com/manaflow-ai/GhosttyTabs/releases/latest/download/appcast.xml"
|
||||
let feedURLString = (infoURL?.isEmpty == false) ? infoURL! : fallback
|
||||
recordFeedURLString(feedURLString, usedFallback: feedURLString == fallback)
|
||||
return feedURLString
|
||||
}
|
||||
|
||||
/// Called when an update is scheduled to install silently,
|
||||
|
|
@ -19,6 +23,41 @@ extension UpdateDriver: SPUUpdaterDelegate {
|
|||
return true
|
||||
}
|
||||
|
||||
func updater(_ updater: SPUUpdater, didFinishLoading appcast: SUAppcast) {
|
||||
let count = appcast.items.count
|
||||
let firstVersion = appcast.items.first?.displayVersionString ?? ""
|
||||
if firstVersion.isEmpty {
|
||||
UpdateLogStore.shared.append("appcast loaded (items=\(count))")
|
||||
} else {
|
||||
UpdateLogStore.shared.append("appcast loaded (items=\(count), first=\(firstVersion))")
|
||||
}
|
||||
}
|
||||
|
||||
func updater(_ updater: SPUUpdater, didFindValidUpdate item: SUAppcastItem) {
|
||||
let version = item.displayVersionString
|
||||
let fileURL = item.fileURL?.absoluteString ?? ""
|
||||
if fileURL.isEmpty {
|
||||
UpdateLogStore.shared.append("valid update found: \(version)")
|
||||
} else {
|
||||
UpdateLogStore.shared.append("valid update found: \(version) (\(fileURL))")
|
||||
}
|
||||
}
|
||||
|
||||
func updaterDidNotFindUpdate(_ updater: SPUUpdater, error: Error) {
|
||||
let nsError = error as NSError
|
||||
let reasonValue = (nsError.userInfo[SPUNoUpdateFoundReasonKey] as? NSNumber)?.intValue
|
||||
let reason = reasonValue.map { SPUNoUpdateFoundReason(rawValue: OSStatus($0)) } ?? nil
|
||||
let reasonText = reason.map(describeNoUpdateFoundReason) ?? "unknown"
|
||||
let userInitiated = (nsError.userInfo[SPUNoUpdateFoundUserInitiatedKey] as? NSNumber)?.boolValue ?? false
|
||||
let latestItem = nsError.userInfo[SPULatestAppcastItemFoundKey] as? SUAppcastItem
|
||||
let latestVersion = latestItem?.displayVersionString ?? ""
|
||||
if latestVersion.isEmpty {
|
||||
UpdateLogStore.shared.append("no update found (reason=\(reasonText), userInitiated=\(userInitiated))")
|
||||
} else {
|
||||
UpdateLogStore.shared.append("no update found (reason=\(reasonText), userInitiated=\(userInitiated), latest=\(latestVersion))")
|
||||
}
|
||||
}
|
||||
|
||||
func updaterWillRelaunchApplication(_ updater: SPUUpdater) {
|
||||
NSApp.invalidateRestorableState()
|
||||
for window in NSApp.windows {
|
||||
|
|
@ -26,3 +65,20 @@ extension UpdateDriver: SPUUpdaterDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func describeNoUpdateFoundReason(_ reason: SPUNoUpdateFoundReason) -> String {
|
||||
switch reason {
|
||||
case .unknown:
|
||||
return "unknown"
|
||||
case .onLatestVersion:
|
||||
return "onLatestVersion"
|
||||
case .onNewerThanLatestVersion:
|
||||
return "onNewerThanLatestVersion"
|
||||
case .systemIsTooOld:
|
||||
return "systemIsTooOld"
|
||||
case .systemIsTooNew:
|
||||
return "systemIsTooNew"
|
||||
@unknown default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue