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

destroy_service.rb « repositories « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c5a0af560660e615c90aab32a346d1aa9d048ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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

      # Because GitlabShellWorker is inside a run_after_commit callback it will
      # never be triggered on a read-only instance.
      #
      # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/223272
      if Gitlab::Database.read_only?
        Repositories::ShellDestroyService.new(current_repository).execute
      else
        container.run_after_commit do
          Repositories::ShellDestroyService.new(current_repository).execute
        end
      end

      log_info("Repository \"#{full_path}\" was removed")

      success
    elsif repo_exists?(disk_path)
      move_error(disk_path)
    else
      success
    end
  rescue Gitlab::Git::Repository::NoRepository
    success
  end
end