diff --git a/mix_tasks/update_geoname_data.ex b/mix_tasks/update_geoname_data.ex index 712c8e4..2f11596 100644 --- a/mix_tasks/update_geoname_data.ex +++ b/mix_tasks/update_geoname_data.ex @@ -8,10 +8,14 @@ defmodule Mix.Tasks.UpdateGeonameData do The data source allCountries.txt clocks in at 1.5GB. Expect this to take a while. """ def run(_) do - # System.cmd("wget", [@allcountries_src, "-O", "/tmp/allCountries.zip"]) - # System.cmd("unzip", ["/tmp/allCountries.zip", "-d", "/tmp"]) + tmp_txt = Path.join(System.tmp_dir!(), "allCountries.txt") - process_geonames_file("/tmp/allCountries.txt") + unless File.exists?(tmp_txt) do + System.cmd("wget", [@allcountries_src, "-O", "/tmp/allCountries.zip"]) + System.cmd("unzip", ["/tmp/allCountries.zip", "-d", "/tmp"]) + end + + process_geonames_file(tmp_txt) end defp process_geonames_file(filename) do