Class: Gitlab::ImportExport::UploadsManager

Inherits:
Object
  • Object
show all
Includes:
CommandLineUtil
Defined in:
lib/gitlab/import_export/uploads_manager.rb

Constant Summary collapse

UPLOADS_BATCH_SIZE =
100

Constants included from CommandLineUtil

CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, CommandLineUtil::CommandLineUtilError, CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, CommandLineUtil::HardLinkError, CommandLineUtil::UNTAR_MASK

Instance Method Summary collapse

Methods included from CommandLineUtil

#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf

Constructor Details

#initialize(project:, shared:, relative_export_path: 'uploads') ⇒ UploadsManager

Returns a new instance of UploadsManager.



10
11
12
13
14
# File 'lib/gitlab/import_export/uploads_manager.rb', line 10

def initialize(project:, shared:, relative_export_path: 'uploads')
  @project = project
  @shared = shared
  @relative_export_path = relative_export_path
end

Instance Method Details

#restoreObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gitlab/import_export/uploads_manager.rb', line 25

def restore
  Dir["#{uploads_export_path}/**/*"].each do |upload|
    next if File.directory?(upload)

    add_upload(upload)
  end

  true
rescue StandardError => e
  @shared.error(e)
  false
end

#saveObject



16
17
18
19
20
21
22
23
# File 'lib/gitlab/import_export/uploads_manager.rb', line 16

def save
  copy_project_uploads

  true
rescue StandardError => e
  @shared.error(e)
  false
end