2018-11-16 19:37:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-15 10:03:31 -04:00
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
|
|
|
class AvatarSaver
|
2022-04-06 11:08:23 -04:00
|
|
|
include DurationMeasuring
|
|
|
|
|
2016-07-15 10:03:31 -04:00
|
|
|
def initialize(project:, shared:)
|
|
|
|
@project = project
|
|
|
|
@shared = shared
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2022-04-06 11:08:23 -04:00
|
|
|
with_duration_measuring do
|
|
|
|
break true unless @project.avatar.exists?
|
2016-07-15 10:03:31 -04:00
|
|
|
|
2022-04-06 11:08:23 -04:00
|
|
|
Gitlab::ImportExport::UploadsManager.new(
|
|
|
|
project: @project,
|
|
|
|
shared: @shared,
|
|
|
|
relative_export_path: 'avatar'
|
|
|
|
).save
|
|
|
|
end
|
2021-04-26 08:09:44 -04:00
|
|
|
rescue StandardError => e
|
2016-07-15 10:03:31 -04:00
|
|
|
@shared.error(e)
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|