Class: Projects::HashedStorage::MigrateRepositoryService

Inherits:
BaseRepositoryService show all
Defined in:
app/services/projects/hashed_storage/migrate_repository_service.rb

Instance Attribute Summary

Attributes inherited from BaseRepositoryService

#logger, #move_design, #move_wiki, #new_disk_path, #old_disk_path, #old_storage_version

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseRepositoryService

#initialize

Methods included from Gitlab::ShellAdapter

#gitlab_shell

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from Projects::HashedStorage::BaseRepositoryService

Instance Method Details

#executeObject


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
42
# File 'app/services/projects/hashed_storage/migrate_repository_service.rb', line 6

def execute
  try_to_set_repository_read_only!

  @old_storage_version = project.storage_version
  project.storage_version = ::Project::HASHED_STORAGE_FEATURES[:repository]

  @new_disk_path = project.disk_path

  result = move_repositories

  if result
    project.set_full_path
    project.track_project_repository
  else
    rollback_folder_move
    project.storage_version = nil
  end

  project.transaction do
    project.save!(validate: false)
    project.set_repository_writable!
  end

  result
rescue Gitlab::Git::CommandError => e
  logger.error("Repository #{project.full_path} failed to upgrade (PROJECT_ID=#{project.id}). Git operation failed: #{e.inspect}")

  rollback_migration!

  false
rescue OpenSSL::Cipher::CipherError => e
  logger.error("Repository #{project.full_path} failed to upgrade (PROJECT_ID=#{project.id}). There is a problem with encrypted attributes: #{e.inspect}")

  rollback_migration!

  false
end