FIX: gunzip the downloaded file

FIX: gunzip the downloaded file

diff --git a/lib/discourse_ip_info.rb b/lib/discourse_ip_info.rb
index df4f6dd..37b0fa2 100644
--- a/lib/discourse_ip_info.rb
+++ b/lib/discourse_ip_info.rb
@@ -33,9 +33,9 @@ class DiscourseIpInfo
       tmp_file_name: "#{name}.gz"
     )
 
-    path = gz_file.path.sub(/\.gz\z/, "")
-    Discourse::Utils.execute_command("gunzip", path)
+    Discourse::Utils.execute_command("gunzip", gz_file.path)
 
+    path = gz_file.path.sub(/\.gz\z/, "")
     FileUtils.mv(path, mmdb_path(name))
   ensure
     gz_file&.close!

GitHub sha: 3bc99e53

not sure why we switched from tar to gzip here?

My goal was to do something akin to what their geoipupdate program does: pass the current md5 to check whether there’s an update. That API returns the db file gzipped as opposed to the tar archive from the download page which has plenty of other unecessary files.

1 Like