mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 23:24:42 +08:00
FIX: use hidden setting for max export file size
This commit is contained in:
@ -869,6 +869,10 @@ files:
|
|||||||
default: 40
|
default: 40
|
||||||
min: 5
|
min: 5
|
||||||
max: 150
|
max: 150
|
||||||
|
max_export_file_size_kb:
|
||||||
|
hidden: true
|
||||||
|
default: 50000
|
||||||
|
max: 1024000
|
||||||
theme_authorized_extensions:
|
theme_authorized_extensions:
|
||||||
default: 'jpg|jpeg|png|woff|woff2|svg|eot|ttf|otf|gif'
|
default: 'jpg|jpeg|png|woff|woff2|svg|eot|ttf|otf|gif'
|
||||||
type: list
|
type: list
|
||||||
|
@ -113,7 +113,11 @@ class Validators::UploadValidator < ActiveModel::Validator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def maximum_file_size(upload, type)
|
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
|
max_size_bytes = max_size_kb.kilobytes
|
||||||
|
|
||||||
if upload.filesize > max_size_bytes
|
if upload.filesize > max_size_bytes
|
||||||
|
@ -20,9 +20,14 @@ describe Validators::UploadValidator do
|
|||||||
it "allows 'gz' as extension when uploading export file" do
|
it "allows 'gz' as extension when uploading export file" do
|
||||||
SiteSetting.authorized_extensions = ""
|
SiteSetting.authorized_extensions = ""
|
||||||
|
|
||||||
created_upload = UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)
|
expect(UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)).to be_valid
|
||||||
expect(created_upload).to be_valid
|
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user