diff options
author | Josef Šimánek <josef.simanek@gmail.com> | 2022-10-29 02:47:14 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-11-11 17:24:08 +0900 |
commit | 7ce0f81fbbd9c2b35e9fe35f5ef040626e284a88 (patch) | |
tree | 7bad4d0b3734a3c075b489cf6bcb53adbefcebbf /lib/rubygems/update_suggestion.rb | |
parent | c7d043065c058f20ce30c61bb3ce127cb15cc0a8 (diff) | |
download | ruby-7ce0f81fbbd9c2b35e9fe35f5ef040626e284a88.tar.gz |
[rubygems/rubygems] Use file in XDG_STATE_HOME directory to store last update check timestamp.
https://github.com/rubygems/rubygems/commit/0fbc4ace8a
Diffstat (limited to 'lib/rubygems/update_suggestion.rb')
-rw-r--r-- | lib/rubygems/update_suggestion.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/rubygems/update_suggestion.rb b/lib/rubygems/update_suggestion.rb index 71c44af3af..d9ac517e49 100644 --- a/lib/rubygems/update_suggestion.rb +++ b/lib/rubygems/update_suggestion.rb @@ -41,24 +41,22 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa return false if Gem.disable_system_update_message return false if ci? - # check makes sense only when we can store of last try - # otherwise we will not be able to prevent annoying update message + # check makes sense only when we can store timestamp of last try + # otherwise we will not be able to prevent "annoying" update message # on each command call - return unless Gem.configuration.config_file_writable? + return unless Gem.configuration.state_file_writable? # load time of last check, ensure the difference is enough to repeat the suggestion check_time = Time.now.to_i - last_update_check = Gem.configuration[:last_update_check] || 0 + last_update_check = Gem.configuration.last_update_check return false if (check_time - last_update_check) < ONE_WEEK # compare current and latest version, this is the part where # latest rubygems spec is fetched from remote - (Gem.rubygems_version < Gem.latest_rubygems_version).tap do |eglible| - if eglible - # store the time of last successful check into config file - Gem.configuration[:last_update_check] = check_time - Gem.configuration.write - end + if (Gem.rubygems_version < Gem.latest_rubygems_version) + # store the time of last successful check into state file + Gem.configuration.last_update_check = check_time + return true end rescue # don't block install command on any problem false |