mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 17:52:39 +02:00
Site model for file limit fix
This commit is contained in:
parent
784ba44785
commit
5b13244712
1 changed files with 13 additions and 2 deletions
|
@ -102,7 +102,8 @@ class Site < Sequel::Model
|
||||||
unlimited_site_creation: true,
|
unlimited_site_creation: true,
|
||||||
custom_ssl_certificates: true,
|
custom_ssl_certificates: true,
|
||||||
no_file_restrictions: true,
|
no_file_restrictions: true,
|
||||||
custom_domains: true
|
custom_domains: true,
|
||||||
|
maximum_site_files: 25000
|
||||||
}
|
}
|
||||||
|
|
||||||
PLAN_FEATURES[:free] = PLAN_FEATURES[:supporter].merge(
|
PLAN_FEATURES[:free] = PLAN_FEATURES[:supporter].merge(
|
||||||
|
@ -113,9 +114,14 @@ class Site < Sequel::Model
|
||||||
unlimited_site_creation: false,
|
unlimited_site_creation: false,
|
||||||
custom_ssl_certificates: false,
|
custom_ssl_certificates: false,
|
||||||
no_file_restrictions: false,
|
no_file_restrictions: false,
|
||||||
custom_domains: false
|
custom_domains: false,
|
||||||
|
maximum_site_files: 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def too_many_files?(file_count=0)
|
||||||
|
(site_files_dataset.count + file_count) > plan_feature(:maximum_site_files)
|
||||||
|
end
|
||||||
|
|
||||||
def plan_feature(key)
|
def plan_feature(key)
|
||||||
PLAN_FEATURES[plan_type.to_sym][key.to_sym]
|
PLAN_FEATURES[plan_type.to_sym][key.to_sym]
|
||||||
end
|
end
|
||||||
|
@ -1103,6 +1109,11 @@ class Site < Sequel::Model
|
||||||
new_size = 0
|
new_size = 0
|
||||||
html_uploaded = false
|
html_uploaded = false
|
||||||
|
|
||||||
|
if too_many_files?(files.length)
|
||||||
|
results << false
|
||||||
|
return results
|
||||||
|
end
|
||||||
|
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
new_size += file[:tempfile].size
|
new_size += file[:tempfile].size
|
||||||
html_uploaded = true if file[:filename].match HTML_REGEX
|
html_uploaded = true if file[:filename].match HTML_REGEX
|
||||||
|
|
Loading…
Add table
Reference in a new issue