Class: Gitlab::ImportExport::Importer

Inherits:
Object
  • Object
show all
Includes:
Allowable, Utils::StrongMemoize
Defined in:
lib/gitlab/import_export/importer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from Allowable

#can?

Constructor Details

#initialize(project) ⇒ Importer

Returns a new instance of Importer.


13
14
15
16
17
18
# File 'lib/gitlab/import_export/importer.rb', line 13

def initialize(project)
  @archive_file = project.import_source
  @current_user = project.creator
  @project = project
  @shared = project.import_export_shared
end

Class Method Details

.imports_repository?Boolean

Returns:

  • (Boolean)

9
10
11
# File 'lib/gitlab/import_export/importer.rb', line 9

def self.imports_repository?
  true
end

Instance Method Details

#executeObject


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gitlab/import_export/importer.rb', line 20

def execute
  if import_file && check_version! && restorers.all?(&:restore) && overwrite_project
    project
  else
    raise Projects::ImportService::Error.new(shared.errors.to_sentence)
  end
rescue => e
  # If some exception was raised could mean that the SnippetsRepoRestorer
  # was not called. This would leave us with snippets without a repository.
  # This is a state we don't want them to be, so we better delete them.
  remove_non_migrated_snippets

  raise Projects::ImportService::Error.new(e.message)
ensure
  remove_base_tmp_dir
  remove_import_file
end