diff options
-rw-r--r-- | app/models/project.rb | 10 | ||||
-rw-r--r-- | app/workers/project_export_worker.rb | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index af62e8ecd90..8781a3cf7a4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1034,4 +1034,14 @@ class Project < ActiveRecord::Base def wiki @wiki ||= ProjectWiki.new(self, self.owner) end + + def add_export_job(current_user_id:) + job_id = ProjectExportWorker.perform_async(current_user_id, self.id) + + if job_id + Rails.logger.info "Export job started for project ID #{self.id} with job ID #{job_id}" + else + Rails.logger.error "Export job failed to start for project ID #{self.id}" + end + end end diff --git a/app/workers/project_export_worker.rb b/app/workers/project_export_worker.rb new file mode 100644 index 00000000000..a1add5395b7 --- /dev/null +++ b/app/workers/project_export_worker.rb @@ -0,0 +1,13 @@ +class ProjectExportWorker + include Sidekiq::Worker + + # TODO: enabled retry - disabled for QA purposes + sidekiq_options queue: :gitlab_shell, retry: false + + def perform(current_user_id, project_id) + current_user = User.find(current_user_id) + project = Project.find(project_id) + ::Projects::ImportExport::ExportService.new(project, current_user).execute + # TODO : Handle errors + end +end |