Module: Storage::LegacyNamespace

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::ShellAdapter
Included in:
Namespace
Defined in:
app/models/concerns/storage/legacy_namespace.rb

Instance Method Summary collapse

Methods included from Gitlab::ShellAdapter

#gitlab_shell

Instance Method Details

#move_dirObject



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
42
43
# File 'app/models/concerns/storage/legacy_namespace.rb', line 9

def move_dir
  proj_with_tags = first_project_with_container_registry_tags

  if proj_with_tags
    raise Gitlab::UpdatePathError, "Namespace #{name} (#{id}) cannot be moved because at least one project (e.g. #{proj_with_tags.name} (#{proj_with_tags.id})) has tags in container registry"
  end

  parent_was = if saved_change_to_parent? && parent_id_before_last_save.present?
                 Namespace.find(parent_id_before_last_save) # raise NotFound early if needed
               end

  if saved_change_to_parent?
    former_parent_full_path = parent_was&.full_path
    parent_full_path = parent&.full_path
    Gitlab::UploadsTransfer.new.move_namespace(path, former_parent_full_path, parent_full_path)
  else
    Gitlab::UploadsTransfer.new.rename_namespace(full_path_before_last_save, full_path)
  end

  # If repositories moved successfully we need to
  # send update instructions to users.
  # However we cannot allow rollback since we moved namespace dir
  # So we basically we mute exceptions in next actions
  begin
    send_update_instructions
    write_projects_repository_config
  rescue StandardError => e
    Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e,
      full_path_before_last_save: full_path_before_last_save,
      full_path: full_path,
      action: 'move_dir')
  end

  true # false would cancel later callbacks but not rollback
end

#prepare_for_destroyObject

Save the storages before the projects are destroyed to use them on after destroy



48
49
50
# File 'app/models/concerns/storage/legacy_namespace.rb', line 48

def prepare_for_destroy
  old_repository_storages
end