import_export.rb 1.36 KB
Newer Older
1 2
# frozen_string_literal: true

3
module Gitlab
4 5 6
  module ImportExport
    extend self

7 8 9
    # For every version update the version history in these docs must be kept up to date:
    # - development/import_export.md
    # - user/project/settings/import_export.md
10
    VERSION = '0.2.4'
11
    FILENAME_LIMIT = 50
12

13
    def export_path(relative_path:)
James Lopez's avatar
James Lopez committed
14
      File.join(storage_path, relative_path)
15 16 17 18 19
    end

    def storage_path
      File.join(Settings.shared['path'], 'tmp/project_exports')
    end
James Lopez's avatar
James Lopez committed
20

21 22 23 24
    def import_upload_path(filename:)
      File.join(storage_path, 'uploads', filename)
    end

James Lopez's avatar
James Lopez committed
25 26 27 28 29 30 31
    def project_filename
      "project.json"
    end

    def project_bundle_filename
      "project.bundle"
    end
32

33 34 35 36 37 38 39 40
    def lfs_objects_filename
      "lfs-objects.json"
    end

    def lfs_objects_storage
      "lfs-objects"
    end

41 42 43 44
    def wiki_repo_bundle_filename
      "project.wiki.bundle"
    end

45
    def config_file
James Lopez's avatar
James Lopez committed
46
      Rails.root.join('lib/gitlab/import_export/import_export.yml')
47 48
    end

49 50 51
    def version_filename
      'VERSION'
    end
James Lopez's avatar
James Lopez committed
52

53
    def export_filename(project:)
54
      basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{project.full_path.tr('/', '_')}"
55 56 57 58

      "#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
    end

James Lopez's avatar
James Lopez committed
59 60 61
    def version
      VERSION
    end
62 63 64 65

    def reset_tokens?
      true
    end
66 67
  end
end
68 69

Gitlab::ImportExport.prepend_if_ee('EE::Gitlab::ImportExport')