mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: warn instead of excepting if MaxMind DBs can't be downloaded (#7600)
This commit is contained in:
committed by
Régis Hanol
parent
3bc99e5372
commit
5bfeef7705
@@ -27,16 +27,20 @@ class DiscourseIpInfo
|
|||||||
def self.mmdb_download(name)
|
def self.mmdb_download(name)
|
||||||
FileUtils.mkdir_p(path)
|
FileUtils.mkdir_p(path)
|
||||||
|
|
||||||
gz_file = FileHelper.download(
|
begin
|
||||||
"https://geolite.maxmind.com/geoip/databases/#{name}/update",
|
gz_file = FileHelper.download(
|
||||||
max_file_size: 100.megabytes,
|
"https://geolite.maxmind.com/geoip/databases/#{name}/update",
|
||||||
tmp_file_name: "#{name}.gz"
|
max_file_size: 100.megabytes,
|
||||||
)
|
tmp_file_name: "#{name}.gz"
|
||||||
|
)
|
||||||
|
|
||||||
|
Discourse::Utils.execute_command("gunzip", gz_file.path)
|
||||||
|
|
||||||
Discourse::Utils.execute_command("gunzip", gz_file.path)
|
path = gz_file.path.sub(/\.gz\z/, "")
|
||||||
|
FileUtils.mv(path, mmdb_path(name))
|
||||||
path = gz_file.path.sub(/\.gz\z/, "")
|
rescue HTTPError => e
|
||||||
FileUtils.mv(path, mmdb_path(name))
|
Rails.logger.warn("MaxMindDB (#{name}) could not be downloaded: #{e}")
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
gz_file&.close!
|
gz_file&.close!
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user