diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /lib/gitlab/import_export | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'lib/gitlab/import_export')
7 files changed, 15 insertions, 12 deletions
diff --git a/lib/gitlab/import_export/command_line_util.rb b/lib/gitlab/import_export/command_line_util.rb index e2f365fcbf8..924ca4e83ea 100644 --- a/lib/gitlab/import_export/command_line_util.rb +++ b/lib/gitlab/import_export/command_line_util.rb @@ -56,7 +56,7 @@ module Gitlab private - def download_or_copy_upload(uploader, upload_path, size_limit: nil) + def download_or_copy_upload(uploader, upload_path, size_limit: 0) if uploader.upload.local? copy_files(uploader.path, upload_path) else @@ -64,7 +64,7 @@ module Gitlab end end - def download(url, upload_path, size_limit: nil) + def download(url, upload_path, size_limit: 0) File.open(upload_path, 'wb') do |file| current_size = 0 @@ -74,7 +74,7 @@ module Gitlab elsif fragment.code == 200 current_size += fragment.bytesize - raise FileOversizedError if size_limit.present? && current_size > size_limit + raise FileOversizedError if size_limit > 0 && current_size > size_limit file.write(fragment) else diff --git a/lib/gitlab/import_export/decompressed_archive_size_validator.rb b/lib/gitlab/import_export/decompressed_archive_size_validator.rb index 2e39f3f38c2..3609df89958 100644 --- a/lib/gitlab/import_export/decompressed_archive_size_validator.rb +++ b/lib/gitlab/import_export/decompressed_archive_size_validator.rb @@ -5,7 +5,6 @@ module Gitlab class DecompressedArchiveSizeValidator include Gitlab::Utils::StrongMemoize - DEFAULT_MAX_BYTES = 10.gigabytes.freeze TIMEOUT_LIMIT = 210.seconds ServiceError = Class.new(StandardError) @@ -22,7 +21,7 @@ module Gitlab end def self.max_bytes - DEFAULT_MAX_BYTES + Gitlab::CurrentSettings.current_application_settings.max_decompressed_archive_size.megabytes end private @@ -52,7 +51,7 @@ module Gitlab if status.success? result = stdout.readline - if result.to_i > @max_bytes + if @max_bytes > 0 && result.to_i > @max_bytes valid_archive = false log_error('Decompressed archive size limit reached') diff --git a/lib/gitlab/import_export/file_importer.rb b/lib/gitlab/import_export/file_importer.rb index 37c83e88ef2..7fb7a9f30a0 100644 --- a/lib/gitlab/import_export/file_importer.rb +++ b/lib/gitlab/import_export/file_importer.rb @@ -74,17 +74,21 @@ module Gitlab download( import_export_upload.remote_import_url, @archive_file, - size_limit: ::Import::GitlabProjects::RemoteFileValidator::FILE_SIZE_LIMIT + size_limit: file_size_limit ) else download_or_copy_upload( import_export_upload.import_file, @archive_file, - size_limit: ::Import::GitlabProjects::RemoteFileValidator::FILE_SIZE_LIMIT + size_limit: file_size_limit ) end end + def file_size_limit + Gitlab::CurrentSettings.current_application_settings.max_import_remote_file_size.megabytes + end + def remove_import_file FileUtils.rm_rf(@archive_file) end diff --git a/lib/gitlab/import_export/project/base_task.rb b/lib/gitlab/import_export/project/base_task.rb index 356e261e251..3cbe3cb7153 100644 --- a/lib/gitlab/import_export/project/base_task.rb +++ b/lib/gitlab/import_export/project/base_task.rb @@ -4,8 +4,6 @@ module Gitlab module ImportExport module Project class BaseTask - include Gitlab::WithRequestStore - def initialize(opts, logger: Logger.new($stdout)) @project_path = opts.fetch(:project_path) @file_path = opts.fetch(:file_path) diff --git a/lib/gitlab/import_export/project/export_task.rb b/lib/gitlab/import_export/project/export_task.rb index 5e105b4653d..3cd0d3f4c2b 100644 --- a/lib/gitlab/import_export/project/export_task.rb +++ b/lib/gitlab/import_export/project/export_task.rb @@ -35,7 +35,7 @@ module Gitlab end def with_export - with_request_store do + ::Gitlab::SafeRequestStore.ensure_request_store do # We are disabling ObjectStorage for `export` # since when direct upload is enabled, remote storage will be used # and Gitlab::ImportExport::AfterExportStrategies::MoveFileStrategy will fail to copy exported archive diff --git a/lib/gitlab/import_export/project/import_export.yml b/lib/gitlab/import_export/project/import_export.yml index 5986c5de441..850c89c1fb1 100644 --- a/lib/gitlab/import_export/project/import_export.yml +++ b/lib/gitlab/import_export/project/import_export.yml @@ -984,9 +984,11 @@ excluded_attributes: notes: - :noteable_id - :review_id + - :namespace_id commit_notes: - :noteable_id - :review_id + - :namespace_id label_links: - :label_id - :target_id diff --git a/lib/gitlab/import_export/project/import_task.rb b/lib/gitlab/import_export/project/import_task.rb index 4ea47a5624a..47cdb630ada 100644 --- a/lib/gitlab/import_export/project/import_task.rb +++ b/lib/gitlab/import_export/project/import_task.rb @@ -25,7 +25,7 @@ module Gitlab # to general Sidekiq clusters/nodes. def with_isolated_sidekiq_job Sidekiq::Testing.fake! do - with_request_store do + ::Gitlab::SafeRequestStore.ensure_request_store do # If you are attempting to import a large project into a development environment, # you may see Gitaly throw an error about too many calls or invocations. # This is due to a n+1 calls limit being set for development setups (not enforced in production) |