Welcome to mirror list, hosted at ThFree Co, Russian Federation.

avatar_restorer.rb « import_export « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ded05f73cf835957cd7a247899db64027595100e (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
module Gitlab
  module ImportExport
    class AvatarRestorer
      def initialize(project:, shared:)
        @project = project
        @shared = shared
      end

      def restore
        return true unless avatar_export_file

        @project.avatar = File.open(avatar_export_file)
        @project.save!
      rescue => e
        @shared.error(e)
        false
      end

      private

      def avatar_export_file
        @avatar_export_file ||= Dir["#{avatar_export_path}/**/*"].first
      end

      def avatar_export_path
        File.join(@shared.export_path, 'avatar')
      end
    end
  end
end