2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
|
|
|
class AvatarSaver
|
2022-06-21 17:19:12 +05:30
|
|
|
include DurationMeasuring
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
def initialize(project:, shared:)
|
|
|
|
@project = project
|
|
|
|
@shared = shared
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2022-06-21 17:19:12 +05:30
|
|
|
with_duration_measuring do
|
|
|
|
break true unless @project.avatar.exists?
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
Gitlab::ImportExport::UploadsManager.new(
|
|
|
|
project: @project,
|
|
|
|
shared: @shared,
|
|
|
|
relative_export_path: 'avatar'
|
|
|
|
).save
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
rescue StandardError => e
|
2016-08-24 12:49:21 +05:30
|
|
|
@shared.error(e)
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|