2020-01-27 22:08:39 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Repositories::DestroyRollbackService < Repositories::BaseService
|
|
|
|
def execute
|
|
|
|
# There is a possibility project does not have repository or wiki
|
|
|
|
return success unless repo_exists?(removal_path)
|
|
|
|
|
|
|
|
# Flush the cache for both repositories.
|
|
|
|
ignore_git_errors { repository.before_delete }
|
|
|
|
|
|
|
|
if mv_repository(removal_path, disk_path)
|
|
|
|
log_info(%Q{Repository "#{removal_path}" moved to "#{disk_path}" for repository "#{full_path}"})
|
|
|
|
|
|
|
|
success
|
2022-03-09 10:08:40 -05:00
|
|
|
elsif repo_exists?(removal_path)
|
|
|
|
# If the repo does not exist, there is no need to return an
|
|
|
|
# error because there was nothing to do.
|
2020-01-27 22:08:39 -05:00
|
|
|
move_error(removal_path)
|
2022-03-09 10:08:40 -05:00
|
|
|
else
|
|
|
|
success
|
2020-01-27 22:08:39 -05:00
|
|
|
end
|
2022-03-09 10:08:40 -05:00
|
|
|
rescue Gitlab::Git::Repository::NoRepository
|
|
|
|
success
|
2020-01-27 22:08:39 -05:00
|
|
|
end
|
|
|
|
end
|