From 9ecebaaea16d206ed20a2f4fc0021a2145c873f5 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Tue, 14 Jun 2016 16:31:03 +0200 Subject: adding notifications stuff and more refactoring for exporting projects --- app/services/notification_service.rb | 8 ++++++++ app/services/projects/create_service.rb | 2 -- app/services/projects/import_export/export_service.rb | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'app/services') diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 91ca82ed3b7..79534a06a1d 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -246,6 +246,14 @@ class NotificationService end end + def project_exported(project, current_user) + mailer.project_was_exported_email(current_user, project).deliver_later + end + + def project_not_exported(project, current_user, errors) + mailer.project_was_not_exported_email(current_user, project, errors).deliver_later + end + protected # Get project users with WATCH notification level diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 7e467541539..ffac357e91d 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -52,8 +52,6 @@ module Projects save_project_and_import_data(import_data) - @project.import_url = download_export_namespace_project_path(@project.namespace, @project) if @project.gitlab_project_import? - @project.import_start if @project.import? after_create_actions if @project.persisted? && !@project.gitlab_project_import? diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb index 25524c1c060..d6752377ce5 100644 --- a/app/services/projects/import_export/export_service.rb +++ b/app/services/projects/import_export/export_service.rb @@ -12,8 +12,9 @@ module Projects def save_all if [version_saver, project_tree_saver, uploads_saver, repo_saver, wiki_repo_saver].all?(&:save) Gitlab::ImportExport::Saver.save(shared: @shared) + notify_success else - cleanup_and_notify_worker + cleanup_and_notify end end @@ -37,10 +38,20 @@ module Projects Gitlab::ImportExport::WikiRepoSaver.new(project: project, shared: @shared) end - def cleanup_and_notify_worker + def cleanup_and_notify FileUtils.rm_rf(@shared.export_path) + + notify_error raise Gitlab::ImportExport::Error.new(@shared.errors.join(', ')) end + + def notify_success + notification_service.project_exported(@project, @current_user) + end + + def notify_error + notification_service.project_not_exported(@project, @current_user, @shared.errors.join(', ')) + end end end end -- cgit v1.2.1