Files
puter/Sources/puter/UpdateController.swift
T
soconnor 0da94715be
Build and test / macos (push) Canceled after 0s
Signed release / release (push) Canceled after 0s
Add advanced monitoring and release infrastructure
2026-08-15 18:23:35 -04:00

38 lines
1.3 KiB
Swift

import Foundation
import Sparkle
@MainActor
final class UpdateController: ObservableObject {
let updaterController: SPUStandardUpdaterController?
init() {
let feed = Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String
let publicKey = Bundle.main.object(forInfoDictionaryKey: "SUPublicEDKey") as? String
if let feed, !feed.isEmpty, let publicKey, !publicKey.isEmpty {
updaterController = SPUStandardUpdaterController(
startingUpdater: true,
updaterDelegate: nil,
userDriverDelegate: nil
)
} else {
updaterController = nil
}
}
var isConfigured: Bool { updaterController != nil }
var canCheckForUpdates: Bool { updaterController?.updater.canCheckForUpdates ?? false }
var automaticallyChecksForUpdates: Bool {
get { updaterController?.updater.automaticallyChecksForUpdates ?? false }
set { updaterController?.updater.automaticallyChecksForUpdates = newValue }
}
var automaticallyDownloadsUpdates: Bool {
get { updaterController?.updater.automaticallyDownloadsUpdates ?? false }
set { updaterController?.updater.automaticallyDownloadsUpdates = newValue }
}
func checkForUpdates() {
updaterController?.checkForUpdates(nil)
objectWillChange.send()
}
}