Commit 8dce2158 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merged rename and transfer into "Move" service.

parent 16117b06
module Geo
class RenameRepositoryService
class MoveRepositoryService
include Gitlab::ShellAdapter
attr_reader :id, :name, :old_path_with_namespace, :new_path_with_namespace
......@@ -15,6 +15,9 @@ module Geo
project = Project.find(id)
project.expire_caches_before_rename(old_path_with_namespace)
# Make sure target directory exists (used when transfering repositories)
project.namespace.ensure_dir_exist
if gitlab_shell.mv_repository(old_path_with_namespace, new_path_with_namespace)
# If repository moved successfully we need to send update instructions to users.
# However we cannot allow rollback since we moved repository
......
......@@ -10,7 +10,7 @@ module Geo
end
def execute
GeoRepositoryRenameWorker.perform_async(id, name, old_path_with_namespace, path_with_namespace)
GeoRepositoryMoveWorker.perform_async(id, name, old_path_with_namespace, path_with_namespace)
end
end
end
class GeoRepositoryRenameWorker
class GeoRepositoryMoveWorker
include Sidekiq::Worker
sidekiq_options queue: :default
def perform(id, name, old_path_with_namespace, new_path_with_namespace)
Geo::RenameRepositoryService.new(id, name, old_path_with_namespace, new_path_with_namespace).execute
Geo::MoveRepositoryService.new(id, name, old_path_with_namespace, new_path_with_namespace).execute
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment