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
IGNORED_FILENAMES =
%w(. ..).freeze

Constants included from CommandLineUtil

CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, 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.


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

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

Class Method Details

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


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

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

Instance Method Details

#importObject


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

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

  remove_symlinks
  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
  remove_symlinks
end