FIX: rescue mmdb download failure (#27556)

* rescue mmdb download failure

If mmdb database fails to download a bootstrap fails. This is a trivial fix for that problem. A more elegant solution might check whether the dataabase was downloaded and provide a helpful error message.

* linting

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
Jay Pfaffman 2024-06-27 14:10:14 -07:00 committed by GitHub
parent 9ab18ed2e3
commit 6a5ee0693d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -55,6 +55,7 @@ class DiscourseIpInfo
end
end
begin
gz_file =
FileHelper.download(
url,
@ -76,6 +77,9 @@ class DiscourseIpInfo
Discourse::Utils.execute_command("tar", "-xzvf", "#{dir}/#{filename}", chdir: dir)
Dir["#{dir}/**/*.mmdb"].each { |f| FileUtils.mv(f, mmdb_path(name)) }
rescue => e
Discourse.warn_exception(e, message: "MaxMind database download failed.")
end
ensure
FileUtils.rm_r(dir, force: true) if dir
gz_file&.close!