mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 21:26:18 +08:00
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:
parent
e765e84941
commit
957b945d25
@ -15,6 +15,7 @@ def get_mmdb_time(root_path)
|
|||||||
|
|
||||||
GEOLITE_DBS.each do |name|
|
GEOLITE_DBS.each do |name|
|
||||||
path = File.join(root_path, "#{name}.mmdb")
|
path = File.join(root_path, "#{name}.mmdb")
|
||||||
|
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
mmdb_time = File.mtime(path)
|
mmdb_time = File.mtime(path)
|
||||||
else
|
else
|
||||||
@ -46,6 +47,7 @@ task "maxminddb:refresh": "environment" do
|
|||||||
|
|
||||||
if GlobalSetting.maxmind_backup_path.present?
|
if GlobalSetting.maxmind_backup_path.present?
|
||||||
backup_mmdb_time = get_mmdb_time(GlobalSetting.maxmind_backup_path)
|
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
|
mmdb_time ||= backup_mmdb_time
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,7 +56,10 @@ task "maxminddb:refresh": "environment" do
|
|||||||
mmdb_time = backup_mmdb_time
|
mmdb_time = backup_mmdb_time
|
||||||
end
|
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..."
|
puts "Downloading MaxMindDB..."
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user