FIX: Support application/gzip theme imports, and improve error message

This commit is contained in:
David Taylor 2019-01-28 11:51:14 +00:00
parent 033cd4f31d
commit 77d26b9df6
2 changed files with 3 additions and 2 deletions

View File

@ -84,7 +84,7 @@ class Admin::ThemesController < Admin::AdminController
rescue RemoteTheme::ImportError => e
render_json_error e.message
end
elsif params[:bundle] || params[:theme] && params[:theme].content_type == "application/x-gzip"
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]
begin
@ -95,7 +95,7 @@ class Admin::ThemesController < Admin::AdminController
render_json_error e.message
end
else
render_json_error status: :unprocessable_entity
render_json_error I18n.t("themes.import_error.unknown_file_type"), status: :unprocessable_entity
end
end

View File

@ -80,6 +80,7 @@ en:
about_json_values: "about.json contains invalid values: %{errors}"
git: "Error cloning git repository, access is denied or repository is not found"
unpack_failed: "Failed to unpack file"
unknown_file_type: "The file you uploaded does not appear to be a valid Discourse theme."
errors:
component_no_user_selectable: "Theme components can't be user-selectable"
component_no_default: "Theme components can't be default theme"