Class: Gitlab::ImportExport::Project::ExportTask

Inherits:
BaseTask
  • Object
show all
Defined in:
lib/gitlab/import_export/project/export_task.rb

Instance Method Summary collapse

Methods included from WithRequestStore

#with_request_store

Constructor Details

#initializeExportTask

Returns a new instance of ExportTask.


7
8
9
10
11
# File 'lib/gitlab/import_export/project/export_task.rb', line 7

def initialize(*)
  super

  @project = namespace.projects.find_by_path(@project_path)
end

Instance Method Details

#exportObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/import_export/project/export_task.rb', line 13

def export
  return error("Project with path: #{project_path} was not found. Please provide correct project path") unless project
  return error("Invalid file path: #{file_path}. Please provide correct file path") unless file_path_exists?

  with_export do
    ::Projects::ImportExport::ExportService.new(project, current_user)
      .execute(Gitlab::ImportExport::AfterExportStrategies::MoveFileStrategy.new(archive_path: file_path))
  end

  return error(project.import_export_shared.errors.join(', ')) if project.import_export_shared.errors.any?

  success('Done!')
rescue Gitlab::ImportExport::Error => e
  error(e.message)
end