summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/uploads_saver.rb
blob: f9ae5079d7c47f799b28dfee7c95dbe24d962d95 (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 UploadsSaver
      include Gitlab::ImportExport::CommandLineUtil

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

      def save
        return true unless File.directory?(uploads_path)

        copy_files(uploads_path, uploads_export_path)
      rescue => e
        @shared.error(e)
        false
      end

      private

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

      def uploads_path
        # TODO: decide what to do with uploads. We will use UUIDs here too?
        File.join(Rails.root.join('public/uploads'), @project.path_with_namespace)
      end
    end
  end
end