Class: Gitlab::ImportExport::FileImporter

Inherits:
Object
  • Object
show all
Includes:
CommandLineUtil
Defined in:
lib/gitlab/import_export/file_importer.rb

Constant Summary collapse

ImporterError =
Class.new(StandardError)
MAX_RETRIES =
8

Constants included from CommandLineUtil

CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, CommandLineUtil::CommandLineUtilError, CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, CommandLineUtil::HardLinkError, CommandLineUtil::UNTAR_MASK

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommandLineUtil

#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf

Constructor Details

#initialize(importable:, archive_file:, shared:) ⇒ FileImporter

Returns a new instance of FileImporter.



16
17
18
19
20
# File 'lib/gitlab/import_export/file_importer.rb', line 16

def initialize(importable:, archive_file:, shared:)
  @importable = importable
  @archive_file = archive_file
  @shared = shared
end

Class Method Details

.import(*args, **kwargs) ⇒ Object



12
13
14
# File 'lib/gitlab/import_export/file_importer.rb', line 12

def self.import(*args, **kwargs)
  new(*args, **kwargs).import
end

Instance Method Details

#importObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gitlab/import_export/file_importer.rb', line 22

def import
  mkdir_p(@shared.export_path)
  mkdir_p(@shared.archive_path)

  clean_extraction_dir!(@shared.export_path)
  copy_archive

  wait_for_archived_file do
    validate_decompressed_archive_size if Feature.enabled?(:validate_import_decompressed_archive_size)
    decompress_archive
  end
rescue StandardError => e
  @shared.error(e)
  false
ensure
  remove_import_file
  clean_extraction_dir!(@shared.export_path)
end