summaryrefslogtreecommitdiff
path: root/app/services/bulk_imports/repository_bundle_export_service.rb
blob: 86159f5189d071c2535b2c1882dac4d33b73ef30 (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 BulkImports
  class RepositoryBundleExportService
    def initialize(repository, export_path, export_filename)
      @repository = repository
      @export_path = export_path
      @export_filename = export_filename
    end

    def execute
      return unless repository_exists?

      repository.bundle_to_disk(bundle_filepath)
    end

    private

    attr_reader :repository, :export_path, :export_filename

    def repository_exists?
      repository.exists? && !repository.empty?
    end

    def bundle_filepath
      File.join(export_path, "#{export_filename}.bundle")
    end
  end
end