summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-06-14 16:31:03 +0200
committerJames Lopez <james@jameslopez.es>2016-06-14 16:31:03 +0200
commit9ecebaaea16d206ed20a2f4fc0021a2145c873f5 (patch)
tree346f9df3661e5cd0e31116fa19270c8e0f3fc032 /app/services
parentfe370b1c396cb3c290fcdb1d716a79ffe5c29169 (diff)
downloadgitlab-ce-9ecebaaea16d206ed20a2f4fc0021a2145c873f5.tar.gz
adding notifications stuff and more refactoring for exporting projects
Diffstat (limited to 'app/services')
-rw-r--r--app/services/notification_service.rb8
-rw-r--r--app/services/projects/create_service.rb2
-rw-r--r--app/services/projects/import_export/export_service.rb15
3 files changed, 21 insertions, 4 deletions
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