summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/avatar_saver.rb
blob: 31ef0490cb3ba479ede14dfd2cc7ec2c4f2f4bbc (plain)
1
2
3
4
5
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
module Gitlab
  module ImportExport
    class AvatarSaver
      include Gitlab::ImportExport::CommandLineUtil

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

      def save
        return true unless @project.avatar.exists?

        Gitlab::ImportExport::UploadsManager.new(
          project: @project,
          shared: @shared,
          relative_export_path: 'avatar',
          from: avatar_path
        ).save
      rescue => e
        @shared.error(e)
        false
      end

      private

      def avatar_path
        @project.avatar.path
      end
    end
  end
end