Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/import_export/decompressed_archive_size_validator.rb')
-rw-r--r--lib/gitlab/import_export/decompressed_archive_size_validator.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/gitlab/import_export/decompressed_archive_size_validator.rb b/lib/gitlab/import_export/decompressed_archive_size_validator.rb
index 3609df89958..13510cb43ca 100644
--- a/lib/gitlab/import_export/decompressed_archive_size_validator.rb
+++ b/lib/gitlab/import_export/decompressed_archive_size_validator.rb
@@ -5,13 +5,10 @@ module Gitlab
class DecompressedArchiveSizeValidator
include Gitlab::Utils::StrongMemoize
- TIMEOUT_LIMIT = 210.seconds
-
ServiceError = Class.new(StandardError)
- def initialize(archive_path:, max_bytes: self.class.max_bytes)
+ def initialize(archive_path:)
@archive_path = archive_path
- @max_bytes = max_bytes
end
def valid?
@@ -20,10 +17,6 @@ module Gitlab
end
end
- def self.max_bytes
- Gitlab::CurrentSettings.current_application_settings.max_decompressed_archive_size.megabytes
- end
-
private
def validate
@@ -32,7 +25,7 @@ module Gitlab
validate_archive_path
- Timeout.timeout(TIMEOUT_LIMIT) do
+ Timeout.timeout(timeout) do
stderr_r, stderr_w = IO.pipe
stdout, wait_threads = Open3.pipeline_r(*command, pgroup: true, err: stderr_w)
@@ -51,7 +44,7 @@ module Gitlab
if status.success?
result = stdout.readline
- if @max_bytes > 0 && result.to_i > @max_bytes
+ if max_bytes > 0 && result.to_i > max_bytes
valid_archive = false
log_error('Decompressed archive size limit reached')
@@ -70,7 +63,7 @@ module Gitlab
valid_archive
rescue Timeout::Error
- log_error('Timeout reached during archive decompression')
+ log_error("Timeout of #{timeout} seconds reached during archive decompression")
pgrps.each { |pgrp| Process.kill(-1, pgrp) } if pgrps
@@ -107,6 +100,14 @@ module Gitlab
import_upload_archive_size: archive_size
)
end
+
+ def timeout
+ Gitlab::CurrentSettings.current_application_settings.decompress_archive_file_timeout
+ end
+
+ def max_bytes
+ Gitlab::CurrentSettings.current_application_settings.max_decompressed_archive_size.megabytes
+ end
end
end
end