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

legacy_relation_tree_saver.rb « import_export « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c6b961ea2109e357c02c4db967838be94eca72c4 (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
# frozen_string_literal: true

module Gitlab
  module ImportExport
    class LegacyRelationTreeSaver
      include Gitlab::ImportExport::CommandLineUtil

      def serialize(exportable, relations_tree)
        Gitlab::ImportExport::FastHashSerializer
          .new(exportable, relations_tree, batch_size: batch_size(exportable))
          .execute
      end

      def save(tree, dir_path, filename)
        mkdir_p(dir_path)

        tree_json = ::JSON.generate(tree)

        File.write(File.join(dir_path, filename), tree_json)
      end

      private

      def batch_size(exportable)
        Gitlab::ImportExport::Json::StreamingSerializer.batch_size(exportable)
      end
    end
  end
end