debian-mirror-gitlab/app/services/repositories/destroy_service.rb

29 lines
881 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
class Repositories::DestroyService < Repositories::BaseService
def execute
return success unless repository
return success unless repo_exists?(disk_path)
# Flush the cache for both repositories. This has to be done _before_
# removing the physical repositories as some expiration code depends on
# Git data (e.g. a list of branch names).
ignore_git_errors { repository.before_delete }
if mv_repository(disk_path, removal_path)
log_info(%Q{Repository "#{disk_path}" moved to "#{removal_path}" for repository "#{full_path}"})
current_repository = repository
2020-04-08 14:13:33 +05:30
container.run_after_commit do
2020-03-13 15:44:24 +05:30
Repositories::ShellDestroyService.new(current_repository).execute
end
2020-04-08 14:13:33 +05:30
log_info("Repository \"#{full_path}\" was removed")
2020-03-13 15:44:24 +05:30
success
else
move_error(disk_path)
end
end
end