-
-
Notifications
You must be signed in to change notification settings - Fork 45
Check for updates once daily #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,11 @@ final class AppUpdateManager { | |||||||||||||
|
|
||||||||||||||
| private var isStarted = false | ||||||||||||||
|
|
||||||||||||||
| /// Sparkle persists this setting in user defaults, which take precedence over the value in | ||||||||||||||
| /// `CotabbyInfo.plist`. Reapplying the product policy repairs older installs that may have saved | ||||||||||||||
| /// a shorter development interval while the plist still gives fresh installs the same default. | ||||||||||||||
| private static let automaticCheckInterval: TimeInterval = 24 * 60 * 60 | ||||||||||||||
|
|
||||||||||||||
| private static let debugCheckForUpdatesOnLaunchArgument = "-Cotabby-check-for-updates-on-launch" | ||||||||||||||
| private static let publicKeyPlaceholder = "REPLACE_WITH_GENERATED_SPARKLE_PUBLIC_ED_KEY" | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -53,18 +58,21 @@ final class AppUpdateManager { | |||||||||||||
| return | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Configure the interval before starting so Sparkle's first scheduling decision uses the | ||||||||||||||
| // daily cadence together with its persisted last-check date. | ||||||||||||||
| let updater = updaterController.updater | ||||||||||||||
| updater.updateCheckInterval = Self.automaticCheckInterval | ||||||||||||||
| updaterController.startUpdater() | ||||||||||||||
| isStarted = true | ||||||||||||||
| log("Sparkle updater started.") | ||||||||||||||
|
|
||||||||||||||
| // Check once on every launch. Sparkle's scheduled check only fires on launch when the | ||||||||||||||
| // interval has already elapsed, so frequent users (who reopen within a day) would never | ||||||||||||||
| // see a check on open. This is a *background* check: it silently does nothing when the app | ||||||||||||||
| // is up to date and only surfaces UI when an update is actually available — unlike | ||||||||||||||
| // `checkForUpdates()`, which always shows a result dialog and is reserved for the manual | ||||||||||||||
| // "Check for Updates" button. The daily `SUScheduledCheckInterval` then covers long-running | ||||||||||||||
| // sessions where the app stays open for days. | ||||||||||||||
| updaterController.updater.checkForUpdatesInBackground() | ||||||||||||||
| // Catch up immediately when the app returns after the daily interval. Recent launches leave | ||||||||||||||
| // the check to Sparkle's scheduler, so reopening Cotabby cannot bypass the daily cadence. | ||||||||||||||
| let shouldCatchUp = updater.lastUpdateCheckDate | ||||||||||||||
| .map { Date().timeIntervalSince($0) >= Self.automaticCheckInterval } ?? true | ||||||||||||||
| if shouldCatchUp { | ||||||||||||||
| updater.checkForUpdatesInBackground() | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+73
to
+75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When automatic update checks are disabled, this catch-up path can still call
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| #if DEBUG | ||||||||||||||
| if ProcessInfo.processInfo.arguments.contains(Self.debugCheckForUpdatesOnLaunchArgument) { | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.