A platform for community discussion. Free, open, simple.
FIX: use hidden setting for max export file size
Arpit Jalanafe3b00c0fac
diff --git a/config/site_settings.yml b/config/site_settings.ymlindex ee0b96c9cc9..aa34a64a8bb 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -869,6 +869,10 @@ files:default: 40min: 5max: 150+ max_export_file_size_kb:+ hidden: true+ default: 50000+ max: 1024000theme_authorized_extensions:default: 'jpg|jpeg|png|woff|woff2|svg|eot|ttf|otf|gif'type: listdiff --git a/lib/validators/upload_validator.rb b/lib/validators/upload_validator.rbindex 5b9da9793df..60074a197f9 100644--- a/lib/validators/upload_validator.rb+++ b/lib/validators/upload_validator.rb@@ -113,7 +113,11 @@ class Validators::UploadValidator < ActiveModel::Validatorenddef 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")+ endmax_size_bytes = max_size_kb.kilobytesif upload.filesize > max_size_bytesdiff --git a/spec/components/validators/upload_validator_spec.rb b/spec/components/validators/upload_validator_spec.rbindex 164d0b0a8e8..f256e2f176e 100644--- a/spec/components/validators/upload_validator_spec.rb+++ b/spec/components/validators/upload_validator_spec.rb@@ -20,9 +20,14 @@ describe Validators::UploadValidator doit "allows 'gz' as extension when uploading export file" doSiteSetting.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_validend+ 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+ endendend