FIX: use hidden setting for max export file size
This commit is contained in:
parent
f0c203a5cf
commit
afe3b00c0f
|
@ -869,6 +869,10 @@ files:
|
|||
default: 40
|
||||
min: 5
|
||||
max: 150
|
||||
max_export_file_size_kb:
|
||||
hidden: true
|
||||
default: 50000
|
||||
max: 1024000
|
||||
theme_authorized_extensions:
|
||||
default: 'jpg|jpeg|png|woff|woff2|svg|eot|ttf|otf|gif'
|
||||
type: list
|
||||
|
|
|
@ -113,7 +113,11 @@ class Validators::UploadValidator < ActiveModel::Validator
|
|||
end
|
||||
|
||||
def maximum_file_size(upload, type)
|
||||
max_size_kb = SiteSetting.send("max_#{type}_size_kb")
|
||||
max_size_kb = if upload.for_export
|
||||
SiteSetting.max_export_file_size_kb
|
||||
else
|
||||
SiteSetting.send("max_#{type}_size_kb")
|
||||
end
|
||||
max_size_bytes = max_size_kb.kilobytes
|
||||
|
||||
if upload.filesize > max_size_bytes
|
||||
|
|
|
@ -20,9 +20,14 @@ describe Validators::UploadValidator do
|
|||
it "allows 'gz' as extension when uploading export file" do
|
||||
SiteSetting.authorized_extensions = ""
|
||||
|
||||
created_upload = UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)
|
||||
expect(created_upload).to be_valid
|
||||
expect(UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)).to be_valid
|
||||
end
|
||||
|
||||
it "allows uses max_export_file_size_kb when uploading export file" do
|
||||
SiteSetting.max_attachment_size_kb = "0"
|
||||
SiteSetting.authorized_extensions = "gz"
|
||||
|
||||
expect(UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)).to be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue