Class: Storage::LegacyProject

Inherits:
Object
  • Object
show all
Defined in:
app/models/storage/legacy_project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ LegacyProject

Returns a new instance of LegacyProject.



9
10
11
# File 'app/models/storage/legacy_project.rb', line 9

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



5
6
7
# File 'app/models/storage/legacy_project.rb', line 5

def project
  @project
end

Instance Method Details

#base_dirString

Base directory

Returns:

  • (String)

    directory where repository is stored



16
17
18
# File 'app/models/storage/legacy_project.rb', line 16

def base_dir
  namespace.full_path
end

#disk_pathString

Disk path is used to build repository and project’s wiki path on disk

Returns:

  • (String)

    combination of base_dir and the repository own name without ‘.git` or `.wiki.git` extensions



23
24
25
# File 'app/models/storage/legacy_project.rb', line 23

def disk_path
  project.full_path
end

#rename_repo(old_full_path: nil, new_full_path: nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/storage/legacy_project.rb', line 27

def rename_repo(old_full_path: nil, new_full_path: nil)
  old_full_path ||= project.full_path_before_last_save
  new_full_path ||= project.build_full_path

  if gitlab_shell.mv_repository(repository_storage, old_full_path, new_full_path)
    # If repository moved successfully we need to send update instructions to users.
    # However we cannot allow rollback since we moved repository
    # So we basically we mute exceptions in next actions
    begin
      gitlab_shell.mv_repository(repository_storage, "#{old_full_path}.wiki", "#{new_full_path}.wiki")
      return true
    rescue StandardError => e
      Gitlab::AppLogger.error("Exception renaming #{old_full_path} -> #{new_full_path}: #{e}")
      # Returning false does not rollback after_* transaction but gives
      # us information about failing some of tasks
      return false
    end
  end

  false
end