Class: Gitlab::ImportExport::SnippetRepoRestorer
- Inherits:
-
RepoRestorer
- Object
- RepoRestorer
- Gitlab::ImportExport::SnippetRepoRestorer
- Includes:
- Import::Framework::ProgressTracking
- Defined in:
- lib/gitlab/import_export/snippet_repo_restorer.rb
Constant Summary collapse
- SnippetRepositoryError =
Class.new(StandardError)
Constants included from Import::Framework::ProgressTracking
Import::Framework::ProgressTracking::CACHE_EXPIRATION
Constants included from CommandLineUtil
CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, CommandLineUtil::CommandLineUtilError, CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, CommandLineUtil::HardLinkError, CommandLineUtil::UNTAR_MASK
Instance Attribute Summary collapse
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes inherited from RepoRestorer
Instance Method Summary collapse
-
#initialize(snippet:, user:, shared:, path_to_bundle:) ⇒ SnippetRepoRestorer
constructor
A new instance of SnippetRepoRestorer.
- #restore ⇒ Object
Methods included from Import::Framework::ProgressTracking
#processed_entry?, #save_processed_entry, #with_progress_tracking
Methods inherited from RepoRestorer
Methods included from CommandLineUtil
#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf
Constructor Details
#initialize(snippet:, user:, shared:, path_to_bundle:) ⇒ SnippetRepoRestorer
Returns a new instance of SnippetRepoRestorer.
12 13 14 15 16 17 18 |
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 12 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
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
8 9 10 |
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 8 def snippet @snippet end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 8 def user @user end |
Instance Method Details
#restore ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gitlab/import_export/snippet_repo_restorer.rb', line 20 def restore with_progress_tracking(**(snippet)) do unless File.exist?(path_to_bundle) @shared.logger.info( message: '[Snippet Import] Missing repository bundle', project_id: snippet.project_id, relation_key: 'snippets', error_messages: "Repository bundle for snippet #{snippet.id} not found" ) ::ImportFailure.create( source: 'SnippetRepoRestorer#restore', relation_key: 'snippets', exception_class: 'MissingBundleFile', exception_message: "Repository bundle for snippet #{snippet.id} not found", correlation_id_value: Labkit::Correlation::CorrelationId.current_or_new_id, project_id: snippet.project_id ) next true end create_repository_from_bundle true end rescue StandardError => e shared.error(e) false end |