From acf3ca4f9b2adb14973516ba11fbad70c0291cb6 Mon Sep 17 00:00:00 2001 From: ruslandoga <67764432+ruslandoga@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:49:20 +0700 Subject: [PATCH] update_geoname_data --- mix_tasks/update_geoname_data.ex | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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