Skip to content

Commit

Permalink
allow larger reports to be extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
evsasse committed Dec 13, 2024
1 parent 7f9a8e1 commit f493a3c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def create
OrganizationUser.create(organization: @organization, user: current_user)

flash[:success] = "Organization '#{@organization.handle}' created successfully!"
redirect_to organization_path(@organization)
redirect_to organizations_path
else
flash[:danger] = @organization.errors.full_messages.to_sentence
redirect_back(fallback_location: organizations_path)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def create

if @project.save
flash[:success] = "Project '#{@project.handle}' created successfully!"
redirect_to project_path(@project)
redirect_to organization_path(@project.organization)
else
flash[:danger] = @project.errors.full_messages.to_sentence
redirect_back(fallback_location: organizations_path)
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require "zip"

class ReportsController < ApplicationController
MAX_SIZE_RESPONSE = 100 * 1024**2 # 100MiB

protect_from_forgery except: %i[bundled_html]

def bundled_html
Expand Down Expand Up @@ -70,7 +68,7 @@ def extract_file
entry = zip_entries.glob(lookup_path).first
return nil if entry.nil?

raise "File too large when extracted" if entry.size > MAX_SIZE_RESPONSE
raise "File too large when extracted" if entry.size > 100.megabytes
entry.get_input_stream.read
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def with_folder_with_unzipped_parts
part.open do |tempzip|
Zip::File.open(tempzip.path) do |zip_entries|
zip_entries.each do |zip_entry|
raise "File too large when extracted" if zip_entry.size > 10.megabytes
raise "File too large when extracted" if zip_entry.size > 100.megabytes

file_path = File.join(tempdir, part.id.to_s, zip_entry.name)
folder_path = file_path.reverse.split("/", 2).last.reverse
Expand Down

0 comments on commit f493a3c

Please sign in to comment.