Class: Gitlab::ImportExport::AvatarRestorer

Inherits:
Object
  • Object
show all
Includes:
Import::Framework::ProgressTracking
Defined in:
lib/gitlab/import_export/avatar_restorer.rb

Constant Summary

Constants included from Import::Framework::ProgressTracking

Import::Framework::ProgressTracking::CACHE_EXPIRATION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Import::Framework::ProgressTracking

#processed_entry?, #save_processed_entry, #with_progress_tracking

Constructor Details

#initialize(project:, shared:) ⇒ AvatarRestorer

Returns a new instance of AvatarRestorer.



10
11
12
13
# File 'lib/gitlab/import_export/avatar_restorer.rb', line 10

def initialize(project:, shared:)
  @project = project
  @shared = shared
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



8
9
10
# File 'lib/gitlab/import_export/avatar_restorer.rb', line 8

def project
  @project
end

Instance Method Details

#restoreObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/import_export/avatar_restorer.rb', line 15

def restore
  return true unless avatar_export_file

  with_progress_tracking(**progress_tracking_options) do
    @project.avatar = File.open(avatar_export_file)
    @project.save!
  end
rescue StandardError => e
  @shared.error(e)
  false
end