summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/file_importer.rb
blob: 0e70d9282d50d1b6228d6e5e2818c9a06befbc9c (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 FileImporter
      include Gitlab::ImportExport::CommandLineUtil

      def self.import(*args)
        new(*args).import
      end

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

      def import
        FileUtils.mkdir_p(@shared.export_path)
        decompress_archive
      rescue => e
        @shared.error(e)
        false
      end

      private

      def decompress_archive
        untar_zxf(archive: @archive_file, dir: @shared.export_path)
      end
    end
  end
end