mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 21:31:04 +08:00
DEV: clean up backup maxmind path
This follows up on 6580025a reuses a list and removes a map that was erronuously there.
This commit is contained in:
@ -158,16 +158,18 @@ def concurrent?
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def geolite_dbs
|
||||||
|
@geolite_dbs ||= %w{
|
||||||
|
GeoLite2-City
|
||||||
|
GeoLite2-ASN
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def get_mmdb_time(root_path)
|
def get_mmdb_time(root_path)
|
||||||
mmdb_time = nil
|
mmdb_time = nil
|
||||||
|
|
||||||
%w{
|
geolite_dbs.each do |name|
|
||||||
GeoLite2-City
|
|
||||||
GeoLite2-ASN
|
|
||||||
}.map 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
|
||||||
@ -182,10 +184,7 @@ end
|
|||||||
def copy_maxmind(from_path, to_path)
|
def copy_maxmind(from_path, to_path)
|
||||||
puts "Copying MaxMindDB from #{from_path} to #{to_path}"
|
puts "Copying MaxMindDB from #{from_path} to #{to_path}"
|
||||||
|
|
||||||
%w{
|
geolite_dbs.each do |name|
|
||||||
GeoLite2-City
|
|
||||||
GeoLite2-ASN
|
|
||||||
}.each do |name|
|
|
||||||
from = File.join(from_path, "#{name}.mmdb")
|
from = File.join(from_path, "#{name}.mmdb")
|
||||||
to = File.join(to_path, "#{name}.mmdb")
|
to = File.join(to_path, "#{name}.mmdb")
|
||||||
FileUtils.cp(from, to, preserve: true)
|
FileUtils.cp(from, to, preserve: true)
|
||||||
@ -214,8 +213,9 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
|||||||
puts "Downloading MaxMindDB..."
|
puts "Downloading MaxMindDB..."
|
||||||
mmdb_thread = Thread.new do
|
mmdb_thread = Thread.new do
|
||||||
begin
|
begin
|
||||||
DiscourseIpInfo.mmdb_download('GeoLite2-City')
|
geolite_dbs.each do |db|
|
||||||
DiscourseIpInfo.mmdb_download('GeoLite2-ASN')
|
DiscourseIpInfo.mmdb_download(db)
|
||||||
|
end
|
||||||
|
|
||||||
if GlobalSetting.maxmind_backup_path.present?
|
if GlobalSetting.maxmind_backup_path.present?
|
||||||
copy_maxmind(DiscourseIpInfo.path, GlobalSetting.maxmind_backup_path)
|
copy_maxmind(DiscourseIpInfo.path, GlobalSetting.maxmind_backup_path)
|
||||||
|
Reference in New Issue
Block a user