DEV: Improve output of `maxminddb:refresh` (#26386)

Why this change?

We want to know when nothing was downloaded because stuff has been
cached on disk
This commit is contained in:
Alan Guo Xiang Tan 2024-03-27 09:50:49 +08:00 committed by GitHub
parent e765e84941
commit 957b945d25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,7 @@ def get_mmdb_time(root_path)
GEOLITE_DBS.each do |name|
path = File.join(root_path, "#{name}.mmdb")
if File.exist?(path)
mmdb_time = File.mtime(path)
else
@ -46,6 +47,7 @@ task "maxminddb:refresh": "environment" do
if GlobalSetting.maxmind_backup_path.present?
backup_mmdb_time = get_mmdb_time(GlobalSetting.maxmind_backup_path)
puts "Detected MaxMindDB backup (downloaded: #{backup_mmdb_time}) at #{GlobalSetting.maxmind_backup_path}"
mmdb_time ||= backup_mmdb_time
end
@ -54,7 +56,10 @@ task "maxminddb:refresh": "environment" do
mmdb_time = backup_mmdb_time
end
next if mmdb_time && mmdb_time >= refresh_days.days.ago
if mmdb_time && mmdb_time >= refresh_days.days.ago
puts "Skip downloading MaxMindDB as it was last downloaded at #{mmdb_time}"
next
end
puts "Downloading MaxMindDB..."