mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06:00
FEATURE: remove "COMPRESS_BROTLI" optional behavior
The compress brotli functionality is no longer optional, this has worked well for years. The name of the ENV var is also confusing cause it does not have a `DISCOURSE_` prefix which caused issues with the web upgrader Brotli support is now unconditionally on
This commit is contained in:
parent
7a7c6af21e
commit
baa7a9836c
@ -54,7 +54,6 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def is_brotli_req?
|
||||
ENV["COMPRESS_BROTLI"] == "1" &&
|
||||
request.env["HTTP_ACCEPT_ENCODING"] =~ /br/
|
||||
end
|
||||
|
||||
|
@ -115,32 +115,28 @@ def gzip(path)
|
||||
raise "gzip compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||
end
|
||||
|
||||
if ENV['COMPRESS_BROTLI']&.to_i == 1
|
||||
# different brotli versions use different parameters
|
||||
ver_out, _ver_err, ver_status = Open3.capture3('brotli --version')
|
||||
if !ver_status.success?
|
||||
# old versions of brotli don't respond to --version
|
||||
def brotli_command(path)
|
||||
"brotli --quality 11 --input #{path} --output #{path}.br"
|
||||
end
|
||||
elsif ver_out >= "brotli 1.0.0"
|
||||
def brotli_command(path)
|
||||
"brotli -f --quality=11 #{path} --output=#{path}.br"
|
||||
end
|
||||
else
|
||||
# not sure what to do here, not expecting this
|
||||
raise "cannot determine brotli version"
|
||||
# different brotli versions use different parameters
|
||||
ver_out, _ver_err, ver_status = Open3.capture3('brotli --version')
|
||||
if !ver_status.success?
|
||||
# old versions of brotli don't respond to --version
|
||||
def brotli_command(path)
|
||||
"brotli --quality 11 --input #{path} --output #{path}.br"
|
||||
end
|
||||
elsif ver_out >= "brotli 1.0.0"
|
||||
def brotli_command(path)
|
||||
"brotli -f --quality=11 #{path} --output=#{path}.br"
|
||||
end
|
||||
else
|
||||
# not sure what to do here, not expecting this
|
||||
raise "cannot determine brotli version"
|
||||
end
|
||||
|
||||
def brotli(path)
|
||||
if ENV['COMPRESS_BROTLI']&.to_i == 1
|
||||
STDERR.puts brotli_command(path)
|
||||
STDERR.puts `#{brotli_command(path)}`
|
||||
raise "brotli compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||
STDERR.puts `chmod +r #{path}.br`.strip
|
||||
raise "chmod failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||
end
|
||||
STDERR.puts brotli_command(path)
|
||||
STDERR.puts `#{brotli_command(path)}`
|
||||
raise "brotli compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||
STDERR.puts `chmod +r #{path}.br`.strip
|
||||
raise "chmod failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||
end
|
||||
|
||||
def compress(from, to)
|
||||
|
@ -5,7 +5,6 @@ describe ApplicationHelper do
|
||||
describe "preload_script" do
|
||||
it "provides brotli links to brotli cdn" do
|
||||
set_cdn_url "https://awesome.com"
|
||||
set_env "COMPRESS_BROTLI", "1"
|
||||
|
||||
helper.request.env["HTTP_ACCEPT_ENCODING"] = 'br'
|
||||
link = helper.preload_script('application')
|
||||
@ -20,7 +19,6 @@ describe ApplicationHelper do
|
||||
global_setting :s3_access_key_id, '123'
|
||||
global_setting :s3_secret_access_key, '123'
|
||||
global_setting :s3_cdn_url, 'https://s3cdn.com'
|
||||
set_env "COMPRESS_BROTLI", "1"
|
||||
end
|
||||
|
||||
after do
|
||||
|
Loading…
Reference in New Issue
Block a user