mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 02:01:15 +08:00
DEV: Introduce maxmind_mirror_url
GlobalSetting (#26458)
Why this change? This allows downloading the MaxMind databases from a mirror in cases where downloading directly from MaxMind's API endpoint is problematic due to API limits.
This commit is contained in:

committed by
GitHub

parent
6c1b320e2e
commit
9182501366
@ -25,16 +25,18 @@ class DiscourseIpInfo
|
||||
end
|
||||
|
||||
def self.mmdb_download(name)
|
||||
if GlobalSetting.maxmind_license_key.blank?
|
||||
STDERR.puts "MaxMind IP database updates require a license"
|
||||
STDERR.puts "Please set DISCOURSE_MAXMIND_LICENSE_KEY to one you generated at https://www.maxmind.com"
|
||||
return
|
||||
end
|
||||
|
||||
FileUtils.mkdir_p(path)
|
||||
|
||||
url =
|
||||
"https://download.maxmind.com/app/geoip_download?license_key=#{GlobalSetting.maxmind_license_key}&edition_id=#{name}&suffix=tar.gz"
|
||||
if GlobalSetting.maxmind_mirror_url.present?
|
||||
URI.join(GlobalSetting.maxmind_mirror_url, "#{name}.tar.gz").to_s
|
||||
else
|
||||
if GlobalSetting.maxmind_license_key.blank?
|
||||
STDERR.puts "MaxMind IP database updates require a license"
|
||||
STDERR.puts "Please set DISCOURSE_MAXMIND_LICENSE_KEY to one you generated at https://www.maxmind.com"
|
||||
return
|
||||
end
|
||||
|
||||
"https://download.maxmind.com/app/geoip_download?license_key=#{GlobalSetting.maxmind_license_key}&edition_id=#{name}&suffix=tar.gz"
|
||||
end
|
||||
|
||||
gz_file =
|
||||
FileHelper.download(
|
||||
|
Reference in New Issue
Block a user