Class: Projects::ImportService

Inherits:
BaseService show all
Defined in:
app/services/projects/import_service.rb

Constant Summary collapse

Error =
Class.new(StandardError)
PermissionError =
Class.new(StandardError)

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#async?Boolean

Returns true if this importer is supposed to perform its work in the background.

This method will only return true if async importing is explicitly supported by an importer class (Gitlab::GithubImport::ParallelImporter for example).

Returns:

  • (Boolean)


14
15
16
# File 'app/services/projects/import_service.rb', line 14

def async?
  has_importer? && !!importer_class.try(:async?)
end

#executeObject



18
19
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
# File 'app/services/projects/import_service.rb', line 18

def execute
  track_start_import

  add_repository_to_project

  validate_repository_size!

  download_lfs_objects

  import_data

  after_execute_hook

  success
rescue Gitlab::HTTP_V2::UrlBlocker::BlockedUrlError, StandardError => e
  Gitlab::Import::ImportFailureService.track(
    project_id: project.id,
    error_source: self.class.name,
    exception: e,
    metrics: true
  )

  message = Projects::ImportErrorFilter.filter_message(e.message)
  error(
    s_(
      "ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}"
    ) % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: message }
  )
end