Revert "FEATURE: admin/user exports are compressed using the zip format (#7784)"

Revert “FEATURE: admin/user exports are compressed using the zip format (#7784)”

This reverts commit 8b2580e20fc508f4e639210f7e64cbf096f95cfc.

diff --git a/Gemfile b/Gemfile
index 85cabaf..b7507fe 100644
--- a/Gemfile
+++ b/Gemfile
@@ -203,8 +203,6 @@ gem "sassc-rails"
 gem 'rotp'
 gem 'rqrcode'
 
-gem 'rubyzip', require: false
-
 gem 'sshkey', require: false
 
 gem 'rchardet', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index f0faf02..b81b19f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -351,7 +351,6 @@ GEM
       guess_html_encoding (>= 0.0.4)
       nokogiri (>= 1.6.0)
     ruby_dep (1.5.0)
-    rubyzip (1.2.3)
     safe_yaml (1.0.5)
     sanitize (5.0.0)
       crass (~> 1.0.2)
@@ -517,7 +516,6 @@ DEPENDENCIES
   rubocop
   ruby-prof
   ruby-readability
-  rubyzip
   sanitize
   sassc
   sassc-rails
diff --git a/app/assets/javascripts/admin/templates/modal/admin-install-theme.hbs b/app/assets/javascripts/admin/templates/modal/admin-install-theme.hbs
index 9a1e18d..153dbc9 100644
--- a/app/assets/javascripts/admin/templates/modal/admin-install-theme.hbs
+++ b/app/assets/javascripts/admin/templates/modal/admin-install-theme.hbs
@@ -44,7 +44,7 @@
 
     {{#if local}}
       <div class="inputs">
-        <input onchange={{action "uploadLocaleFile"}} type="file" id="file-input" accept='.dcstyle.json,application/json,.tar.gz,application/x-gzip,.tar.zip,application/zip'><br>
+        <input onchange={{action "uploadLocaleFile"}} type="file" id="file-input" accept='.dcstyle.json,application/json,.tar.gz,application/x-gzip'><br>
         <span class="description">{{i18n 'admin.customize.theme.import_file_tip'}}</span>
       </div>
     {{/if}}
diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb
index 4def5bd..5389269 100644
--- a/app/controllers/admin/themes_controller.rb
+++ b/app/controllers/admin/themes_controller.rb
@@ -88,7 +88,7 @@ class Admin::ThemesController < Admin::AdminController
       rescue RemoteTheme::ImportError => e
         render_json_error e.message
       end
-    elsif params[:bundle] || (params[:theme] && ["application/x-gzip", "application/gzip", "application/zip"].include?(params[:theme].content_type))
+    elsif params[:bundle] || (params[:theme] && ["application/x-gzip", "application/gzip"].include?(params[:theme].content_type))
       # params[:bundle] used by theme CLI. params[:theme] used by admin UI
       bundle = params[:bundle] || params[:theme]
       theme_id = params[:theme_id]
@@ -252,7 +252,6 @@ class Admin::ThemesController < Admin::AdminController
 
     exporter = ThemeStore::TgzExporter.new(@theme)
     file_path = exporter.package_filename
-
     headers['Content-Length'] = File.size(file_path).to_s
     send_data File.read(file_path),
       filename: File.basename(file_path),
diff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rb
index d8d3a72..e1b5739 100644
--- a/app/jobs/regular/export_csv_file.rb
+++ b/app/jobs/regular/export_csv_file.rb
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 require 'csv'
-require 'zip'
 require_dependency 'system_message'
 require_dependency 'upload_creator'
 
@@ -54,19 +53,18 @@ module Jobs
       # ensure directory exists
       FileUtils.mkdir_p(UserExport.base_directory) unless Dir.exists?(UserExport.base_directory)
 
-      # Generate a compressed CSV file
-      csv_to_export = CSV.generate do |csv|
+      # write to CSV file
+      CSV.open(absolute_path, "w") do |csv|
         csv << get_header if @entity != "report"
         public_send(export_method).each { |d| csv << d }
       end
 
-      compressed_file_path = "#{absolute_path}.zip"
-      Zip::File.open(compressed_file_path, Zip::File::CREATE) do |zipfile|
-        zipfile.get_output_stream(file_name) { |f| f.puts csv_to_export }
-      end
+      # compress CSV file
+      system('gzip', '-5', absolute_path)
 
       # create upload
       upload = nil
+      compressed_file_path = "#{absolute_path}.gz"
 
       if File.exist?(compressed_file_path)
         File.open(compressed_file_path) do |file|
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index d450f80..aad6399 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3514,7 +3514,7 @@ en:
           delete_upload_confirm: "Delete this upload? (Theme CSS may stop working!)"
           import_web_tip: "Repository containing theme"
           import_web_advanced: "Advanced..."
-          import_file_tip: ".tar.gz, .tar.zip, or .dcstyle.json file containing theme"
+          import_file_tip: ".tar.gz or .dcstyle.json file containing theme"
           is_private: "Theme is in a private git repository"
           remote_branch: "Branch name (optional)"
           public_key: "Grant the following public key access to the repo:"
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 014c84b..74a2b8e 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2668,7 +2668,7 @@ en:
 
         The above download link will be valid for 48 hours.
 
-        The data is compressed as a zip archive. If the archive does not extract itself when you open it, use the tool recommended here: https://www.7-zip.org/
+        The data is compressed as a gzip archive. If the archive does not extract itself when you open it, use the tools recommended here: https://www.gzip.org/#faq4
 
     csv_export_failed:
       title: "CSV Export Failed"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index f29155b..1a9fbb9 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1048,7 +1048,7 @@ files:
     list_type: compact
   export_authorized_extensions:
     hidden: true
-    default: "zip"
+    default: "gz"
     type: list
     list_type: compact
   responsive_post_image_sizes:
diff --git a/lib/theme_store/tgz_exporter.rb b/lib/theme_store/tgz_exporter.rb
index d0d8cef..824a874 100644
--- a/lib/theme_store/tgz_exporter.rb
+++ b/lib/theme_store/tgz_exporter.rb
@@ -1,7 +1,5 @@
 # frozen_string_literal: true
 
-require 'zip'
-
 module ThemeStore; end
 
 class ThemeStore::TgzExporter
@@ -60,19 +58,11 @@ class ThemeStore::TgzExporter
   private
   def export_package
     export_to_folder
-
     Dir.chdir(@temp_folder) do
       tar_filename = "#{@export_name}.tar"
       Discourse::Utils.execute_command('tar', '--create', '--file', tar_filename, @export_name, failure_message: "Failed to tar theme.")
-
-      zip_filename = "#{tar_filename}.zip"
-      absolute_path = "#{@temp_folder}/#{tar_filename}"
-      Zip::File.open(zip_filename, Zip::File::CREATE) do |zipfile|
-        zipfile.add(tar_filename, absolute_path)
-        zipfile.close
-      end
-
-      "#{absolute_path}.zip"
+      Discourse::Utils.execute_command('gzip', '-5', tar_filename, failure_message: "Failed to gzip archive.")
+      "#{@temp_folder}/#{tar_filename}.gz"
     end
   end
 
diff --git a/lib/theme_store/tgz_importer.rb b/lib/theme_store/tgz_importer.rb
index e6198ee..5dfb071 100644
--- a/lib/theme_store/tgz_importer.rb
+++ b/lib/theme_store/tgz_importer.rb
@@ -1,7 +1,5 @@
 # frozen_string_literal: true
 
-require 'zip'
-
 module ThemeStore; end
 
 class ThemeStore::TgzImporter
@@ -15,21 +13,8 @@ class ThemeStore::TgzImporter
 
   def import!
     FileUtils.mkdir(@temp_folder)
-
-    if @filename.include?('.zip')
-      name = @filename.split('/').last.gsub('.zip', '')
-
-      Dir.chdir(@temp_folder) do
-        Zip::File.open(@filename) do |zip_file|
-          zip_file.each { |entry| entry.extract(name) }
-        end
-
-        Discourse::Utils.execute_command("tar", "-xvf", name, "--strip", "1")
-      end
-    else
-      Dir.chdir(@temp_folder) do
-        Discourse::Utils.execute_command("tar", "-xzvf", @filename, "--strip", "1")
-      end
+    Dir.chdir(@temp_folder) do
+      Discourse::Utils.execute_command("tar", "-xzvf", @filename, "--strip", "1")
     end
   rescue RuntimeError
     raise RemoteTheme::ImportError, I18n.t("themes.import_error.unpack_failed")
diff --git a/spec/components/theme_store/tgz_exporter_spec.rb b/spec/components/theme_store/tgz_exporter_spec.rb

[... diff too long, it was truncated ...]

GitHub sha: f89bd555

FEATURE: Gz to zip for exports (#7889)