From 957b945d258a1023f0623a99f15b1accfa68aaa4 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 27 Mar 2024 09:50:49 +0800 Subject: [PATCH] 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 --- lib/tasks/maxminddb.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/maxminddb.rake b/lib/tasks/maxminddb.rake index 011825d9d8f..4e879d5c6b8 100644 --- a/lib/tasks/maxminddb.rake +++ b/lib/tasks/maxminddb.rake @@ -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..."