Class: Gitlab::ImportExport::SnippetRepoRestorer

Inherits:
RepoRestorer
  • Object
show all
Defined in:
lib/gitlab/import_export/snippet_repo_restorer.rb

Constant Summary collapse

SnippetRepositoryError =
Class.new(StandardError)

Constants included from CommandLineUtil

CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::UNTAR_MASK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommandLineUtil

#mkdir_p, #tar_czf, #untar_zxf

Constructor Details

#initialize(snippet:, user:, shared:, path_to_bundle:) ⇒ SnippetRepoRestorer

Returns a new instance of SnippetRepoRestorer.


10
11
12
13
14
15
16
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 10

def initialize(snippet:, user:, shared:, path_to_bundle:)
  @snippet = snippet
  @user = user
  @repository = snippet.repository
  @path_to_bundle = path_to_bundle.to_s
  @shared = shared
end

Instance Attribute Details

#snippetObject (readonly)

Returns the value of attribute snippet


6
7
8
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 6

def snippet
  @snippet
end

#userObject (readonly)

Returns the value of attribute user


6
7
8
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 6

def user
  @user
end

Instance Method Details

#restoreObject


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 18

def restore
  if File.exist?(path_to_bundle)
    create_repository_from_bundle
  else
    create_repository_from_db
  end

  true
rescue => e
  shared.error(e)
  false
end