summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/uploads_restorer.rb
blob: 25f859362278b588df365bf97f331a3e1671f2d5 (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
module Gitlab
  module ImportExport
    class UploadsRestorer < UploadsSaver
      def restore
        if Gitlab::ImportExport.object_storage?
          Gitlab::ImportExport::UploadsManager.new(
            project: @project,
            shared: @shared
          ).restore
        elsif File.directory?(uploads_export_path)
          copy_files(uploads_export_path, uploads_path)

          true
        else
          true # Proceed without uploads
        end
      rescue => e
        @shared.error(e)
        false
      end

      def uploads_path
        FileUploader.absolute_base_dir(@project)
      end

      def uploads_export_path
        @uploads_export_path ||= File.join(@shared.export_path, 'uploads')
      end
    end
  end
end