From e278a1cefe7845ebab4b16f2bfaead028a7b94f4 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Mon, 11 Feb 2019 01:32:36 -0800 Subject: [PATCH] Prevent controller from sending huge zipball --- app/site_files.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/site_files.rb b/app/site_files.rb index 2c79fe2a..a347fe78 100644 --- a/app/site_files.rb +++ b/app/site_files.rb @@ -171,6 +171,12 @@ end get '/site_files/:username.zip' do |username| require_login + + if current_site.too_big_to_download? + flash[:error] = 'Cannot download site as zip as it is too large (or contains too many files)' + redirect '/dashboard' + end + zipfile_path = current_site.files_zip content_type 'application/octet-stream' attachment "neocities-#{current_site.username}.zip"