mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-08-12 10:04:49 +00:00
fix(mac): update badge always visible due to version prefix mismatch
GitHub asset name includes a v prefix (v0.8.0) while CFBundleShortVersionString does not (0.8.0). Strip the prefix before comparing. Also capture stderr on update failure so the button doesn't hang on "Updating..." forever.
This commit is contained in:
parent
44d5ffa03f
commit
dba33428ca
1 changed files with 18 additions and 2 deletions
|
|
@ -16,7 +16,9 @@ final class UpdateChecker {
|
|||
var updateAvailable: Bool {
|
||||
guard let latest = latestVersion else { return false }
|
||||
let current = currentVersion
|
||||
return !current.isEmpty && current != "dev" && latest != current
|
||||
let normalizedLatest = latest.hasPrefix("v") ? String(latest.dropFirst()) : latest
|
||||
let normalizedCurrent = current.hasPrefix("v") ? String(current.dropFirst()) : current
|
||||
return !normalizedCurrent.isEmpty && normalizedCurrent != "dev" && normalizedLatest != normalizedCurrent
|
||||
}
|
||||
|
||||
var currentVersion: String {
|
||||
|
|
@ -63,8 +65,22 @@ final class UpdateChecker {
|
|||
updateError = nil
|
||||
|
||||
let process = CodeburnCLI.makeProcess(subcommand: ["menubar", "--force"])
|
||||
let errPipe = Pipe()
|
||||
process.standardOutput = FileHandle.nullDevice
|
||||
process.standardError = FileHandle.nullDevice
|
||||
process.standardError = errPipe
|
||||
|
||||
process.terminationHandler = { [weak self] proc in
|
||||
let errData = errPipe.fileHandleForReading.readDataToEndOfFile()
|
||||
let stderr = String(data: errData, encoding: .utf8) ?? ""
|
||||
Task { @MainActor in
|
||||
guard let self else { return }
|
||||
if proc.terminationStatus != 0 {
|
||||
self.isUpdating = false
|
||||
self.updateError = stderr.isEmpty ? "Update failed (exit \(proc.terminationStatus))" : stderr
|
||||
NSLog("CodeBurn: update failed (exit \(proc.terminationStatus)): \(stderr)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
try process.run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue