2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FIX: issue 1538. After upgrading and before a new version check request has been made, dashboard might still say that an update is available.

This commit is contained in:
Neil Lalonde 2013-11-04 12:51:01 -05:00
parent 5e69b277ea
commit ede59a4386
10 changed files with 133 additions and 75 deletions

View file

@ -24,20 +24,27 @@ module DiscourseUpdates
# Handle cases when version check data is old so we report something that makes sense
if (version_info.updated_at.nil? or
(version_info.missing_versions_count == 0 and version_info.latest_version != version_info.installed_version) or
(version_info.missing_versions_count != 0 and version_info.latest_version == version_info.installed_version))
if (version_info.updated_at.nil? or # never performed a version check
last_installed_version != Discourse::VERSION::STRING or # upgraded since the last version check
(version_info.missing_versions_count == 0 and version_info.latest_version != version_info.installed_version) or # old data
(version_info.missing_versions_count != 0 and version_info.latest_version == version_info.installed_version)) # old data
Jobs.enqueue(:version_check, all_sites: true)
end
if !version_info.updated_at.nil? and version_info.latest_version == version_info.installed_version
version_info.missing_versions_count = 0
version_info.version_check_pending = true
unless version_info.updated_at.nil?
version_info.missing_versions_count = 0
version_info.critical_updates = false
end
end
end
version_info
end
# last_installed_version is the installed version at the time of the last version check
def last_installed_version
$redis.get last_installed_version_key
end
def latest_version
$redis.get latest_version_key
end
@ -59,7 +66,7 @@ module DiscourseUpdates
$redis.set updated_at_key, time_with_zone.as_json
end
['latest_version', 'missing_versions_count', 'critical_updates_available'].each do |name|
['last_installed_version', 'latest_version', 'missing_versions_count', 'critical_updates_available'].each do |name|
eval "define_method :#{name}= do |arg|
$redis.set #{name}_key, arg
end"
@ -68,6 +75,10 @@ module DiscourseUpdates
private
def last_installed_version_key
'last_installed_version'
end
def latest_version_key
'discourse_latest_version'
end