mirror of
https://github.com/neocities/neocities.git
synced 2025-07-21 10:06:00 +02:00
limit dl to 1 per hour
This commit is contained in:
parent
19050fea82
commit
9f96150b2d
2 changed files with 17 additions and 0 deletions
|
@ -189,9 +189,17 @@ end
|
||||||
get '/site_files/:username.zip' do |username|
|
get '/site_files/:username.zip' do |username|
|
||||||
require_login
|
require_login
|
||||||
|
|
||||||
|
if !current_site.dl_queued_at.nil? && current_site.dl_queued_at > 1.hour.ago
|
||||||
|
flash[:error] = 'Site downloads are currently limited to once per hour, please try again later.'
|
||||||
|
redirect request.referer
|
||||||
|
end
|
||||||
|
|
||||||
content_type 'application/zip'
|
content_type 'application/zip'
|
||||||
attachment "neocities-#{current_site.username}.zip"
|
attachment "neocities-#{current_site.username}.zip"
|
||||||
|
|
||||||
|
current_site.dl_queued_at = Time.now
|
||||||
|
current_site.save_changes validate: false
|
||||||
|
|
||||||
directory_path = current_site.files_path
|
directory_path = current_site.files_path
|
||||||
|
|
||||||
stream do |out|
|
stream do |out|
|
||||||
|
|
9
migrations/118_site_dl_queued_at.rb
Normal file
9
migrations/118_site_dl_queued_at.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Sequel.migration do
|
||||||
|
up {
|
||||||
|
DB.add_column :sites, :dl_queued_at, Time
|
||||||
|
}
|
||||||
|
|
||||||
|
down {
|
||||||
|
DB.drop_column :sites, :dl_queued_at
|
||||||
|
}
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue