Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-26 21:09:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-26 21:09:24 +0300
commit619d0b6922a6cf95d291fbbf5fa3d09e772a1ea8 (patch)
treefb8f8e036cec1b32166206bb5102af6c5dca8cfe /app/services
parent17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/groups/import_export/export_service.rb16
-rw-r--r--app/services/groups/import_export/import_service.rb2
-rw-r--r--app/services/lfs/lock_file_service.rb4
-rw-r--r--app/services/lfs/unlock_file_service.rb4
-rw-r--r--app/services/projects/import_export/export_service.rb22
5 files changed, 24 insertions, 24 deletions
diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb
index 2c3975961a8..aa484e7203c 100644
--- a/app/services/groups/import_export/export_service.rb
+++ b/app/services/groups/import_export/export_service.rb
@@ -18,6 +18,8 @@ module Groups
end
save!
+ ensure
+ cleanup
end
private
@@ -28,7 +30,7 @@ module Groups
if savers.all?(&:save)
notify_success
else
- cleanup_and_notify_error!
+ notify_error!
end
end
@@ -37,21 +39,19 @@ module Groups
end
def tree_exporter
- Gitlab::ImportExport::GroupTreeSaver.new(group: @group, current_user: @current_user, shared: @shared, params: @params)
+ Gitlab::ImportExport::Group::TreeSaver.new(group: @group, current_user: @current_user, shared: @shared, params: @params)
end
def file_saver
Gitlab::ImportExport::Saver.new(exportable: @group, shared: @shared)
end
- def cleanup_and_notify_error
- FileUtils.rm_rf(shared.export_path)
-
- notify_error
+ def cleanup
+ FileUtils.rm_rf(shared.archive_path) if shared&.archive_path
end
- def cleanup_and_notify_error!
- cleanup_and_notify_error
+ def notify_error!
+ notify_error
raise Gitlab::ImportExport::Error.new(shared.errors.to_sentence)
end
diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb
index 628c8f5bac0..57d2d9855d1 100644
--- a/app/services/groups/import_export/import_service.rb
+++ b/app/services/groups/import_export/import_service.rb
@@ -34,7 +34,7 @@ module Groups
end
def restorer
- @restorer ||= Gitlab::ImportExport::GroupTreeRestorer.new(user: @current_user,
+ @restorer ||= Gitlab::ImportExport::Group::TreeRestorer.new(user: @current_user,
shared: @shared,
group: @group,
group_hash: nil)
diff --git a/app/services/lfs/lock_file_service.rb b/app/services/lfs/lock_file_service.rb
index 383a0d6b4e3..1b283018c16 100644
--- a/app/services/lfs/lock_file_service.rb
+++ b/app/services/lfs/lock_file_service.rb
@@ -4,13 +4,13 @@ module Lfs
class LockFileService < BaseService
def execute
unless can?(current_user, :push_code, project)
- raise Gitlab::GitAccess::UnauthorizedError, 'You have no permissions'
+ raise Gitlab::GitAccess::ForbiddenError, 'You have no permissions'
end
create_lock!
rescue ActiveRecord::RecordNotUnique
error('already locked', 409, current_lock)
- rescue Gitlab::GitAccess::UnauthorizedError => ex
+ rescue Gitlab::GitAccess::ForbiddenError => ex
error(ex.message, 403)
rescue => ex
error(ex.message, 500)
diff --git a/app/services/lfs/unlock_file_service.rb b/app/services/lfs/unlock_file_service.rb
index ea5a67b727f..a13e89904a0 100644
--- a/app/services/lfs/unlock_file_service.rb
+++ b/app/services/lfs/unlock_file_service.rb
@@ -4,11 +4,11 @@ module Lfs
class UnlockFileService < BaseService
def execute
unless can?(current_user, :push_code, project)
- raise Gitlab::GitAccess::UnauthorizedError, _('You have no permissions')
+ raise Gitlab::GitAccess::ForbiddenError, _('You have no permissions')
end
unlock_file
- rescue Gitlab::GitAccess::UnauthorizedError => ex
+ rescue Gitlab::GitAccess::ForbiddenError => ex
error(ex.message, 403)
rescue ActiveRecord::RecordNotFound
error(_('Lock not found'), 404)
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb
index 38859c1efa4..77fddc44085 100644
--- a/app/services/projects/import_export/export_service.rb
+++ b/app/services/projects/import_export/export_service.rb
@@ -14,6 +14,8 @@ module Projects
save_all!
execute_after_export_action(after_export_strategy)
+ ensure
+ cleanup
end
private
@@ -24,7 +26,7 @@ module Projects
return unless after_export_strategy
unless after_export_strategy.execute(current_user, project)
- cleanup_and_notify_error
+ notify_error
end
end
@@ -33,7 +35,7 @@ module Projects
Gitlab::ImportExport::Saver.save(exportable: project, shared: shared)
notify_success
else
- cleanup_and_notify_error!
+ notify_error!
end
end
@@ -54,7 +56,7 @@ module Projects
end
def project_tree_saver
- Gitlab::ImportExport::ProjectTreeSaver.new(project: project, current_user: current_user, shared: shared, params: params)
+ Gitlab::ImportExport::Project::TreeSaver.new(project: project, current_user: current_user, shared: shared, params: params)
end
def uploads_saver
@@ -73,16 +75,12 @@ module Projects
Gitlab::ImportExport::LfsSaver.new(project: project, shared: shared)
end
- def cleanup_and_notify_error
- Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{shared.errors.join(', ')}") # rubocop:disable Gitlab/RailsLogger
-
- FileUtils.rm_rf(shared.export_path)
-
- notify_error
+ def cleanup
+ FileUtils.rm_rf(shared.archive_path) if shared&.archive_path
end
- def cleanup_and_notify_error!
- cleanup_and_notify_error
+ def notify_error!
+ notify_error
raise Gitlab::ImportExport::Error.new(shared.errors.to_sentence)
end
@@ -92,6 +90,8 @@ module Projects
end
def notify_error
+ Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{shared.errors.join(', ')}") # rubocop:disable Gitlab/RailsLogger
+
notification_service.project_not_exported(project, current_user, shared.errors)
end
end