From 0c90b847fdf975abc207f44cb0b39c2fbb427f1e Mon Sep 17 00:00:00 2001 From: Marco Schmalz Date: Wed, 4 Oct 2017 21:16:40 +0200 Subject: [PATCH 1/3] No auto check for updates when 'core.automaticallyUpdate' is set --- lib/package-manager.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/package-manager.coffee b/lib/package-manager.coffee index 1a717bbf..182a1edd 100644 --- a/lib/package-manager.coffee +++ b/lib/package-manager.coffee @@ -13,7 +13,7 @@ class PackageManager @packagePromises = [] @apmCache = loadOutdated: - value: null + value: [] expiry: 0 @emitter = new Emitter @@ -132,6 +132,10 @@ class PackageManager # Short circuit if we have cached data. else if @apmCache.loadOutdated.value and @apmCache.loadOutdated.expiry > Date.now() return callback(null, @apmCache.loadOutdated.value) + # Return cached or empty package lists, if automatic updates are disabled, + # even if cache has expired, as long as no cache rebuilding is being forced. + else if (not atom.config.get('core.automaticallyUpdate')) + return callback(null, @apmCache.loadOutdated.value) args = ['outdated', '--json'] version = atom.getVersion() @@ -169,7 +173,7 @@ class PackageManager clearOutdatedCache: -> @apmCache.loadOutdated = - value: null + value: [] expiry: 0 loadPackage: (packageName, callback) -> From 2591673cf32c33b9fca7ed61ee253a72b2e6df42 Mon Sep 17 00:00:00 2001 From: Marco Schmalz Date: Wed, 4 Oct 2017 23:30:43 +0200 Subject: [PATCH 2/3] Show warning when automatic update checks are disabled --- lib/updates-panel.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/updates-panel.js b/lib/updates-panel.js index 424be5e8..6023c35d 100644 --- a/lib/updates-panel.js +++ b/lib/updates-panel.js @@ -82,6 +82,10 @@ export default class UpdatesPanel {
The following packages are pinned to their current version and are not being checked for updates: { this.packageManager.getVersionPinnedPackages().join(', ') }
+
+ Automatically checking for updates is disabled. To enable, check the Automatically Update option + in { atom.workspace.open('atom://config/core') }}>Core settings. +
{`Checking for updates\u2026`}
All of your installed packages are up to date!
@@ -118,6 +122,12 @@ export default class UpdatesPanel { if (this.packageManager.getVersionPinnedPackages().length === 0) { this.refs.versionPinnedPackagesMessage.style.display = 'none' } + + if (atom.config.get('core.automaticallyUpdate')) { + this.refs.automaticallyUpdateDisabledMessage.style.display = 'none' + } else { + this.refs.automaticallyUpdateDisabledMessage.style.display = '' + } } // Check for updates and display them From bbfd88bded289994c8c0f9f2939a5962492e79d3 Mon Sep 17 00:00:00 2001 From: Marco Schmalz Date: Wed, 4 Oct 2017 23:33:56 +0200 Subject: [PATCH 3/3] Hide noUpdatesMessage when automatic check for updates is disabled Show "All of your installed packages are up to date!" only after checking for updates when no automatic checks for updates are performed. --- lib/updates-panel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/updates-panel.js b/lib/updates-panel.js index 6023c35d..fc9b1676 100644 --- a/lib/updates-panel.js +++ b/lib/updates-panel.js @@ -140,7 +140,7 @@ export default class UpdatesPanel { try { this.availableUpdates = await this.packageManager.getOutdated(clearCache) this.refs.checkButton.disabled = false - this.addUpdateViews() + this.addUpdateViews(clearCache) } catch (error) { this.refs.checkButton.disabled = false this.refs.checkingMessage.style.display = 'none' @@ -148,14 +148,14 @@ export default class UpdatesPanel { } } - addUpdateViews () { + addUpdateViews (forcedUpdate) { if (this.availableUpdates.length > 0) { this.refs.updateAllButton.style.display = '' this.refs.updateAllButton.disabled = false } this.refs.checkingMessage.style.display = 'none' this.clearPackageCards() - if (this.availableUpdates.length === 0) { + if (this.availableUpdates.length === 0 && (forcedUpdate || atom.config.get('core.automaticallyUpdate'))) { this.refs.noUpdatesMessage.style.display = '' }