Class: Gitlab::ImportExport::Shared

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/import_export/shared.rb

Constant Summary collapse

LOCKS_DIRECTORY =
'locks'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exportable) ⇒ Shared

Returns a new instance of Shared.


30
31
32
33
34
# File 'lib/gitlab/import_export/shared.rb', line 30

def initialize(exportable)
  @exportable = exportable
  @errors     = []
  @logger     = Gitlab::Import::Logger.build
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors


26
27
28
# File 'lib/gitlab/import_export/shared.rb', line 26

def errors
  @errors
end

#exportableObject (readonly)

Returns the value of attribute exportable


26
27
28
# File 'lib/gitlab/import_export/shared.rb', line 26

def exportable
  @exportable
end

#loggerObject (readonly)

Returns the value of attribute logger


26
27
28
# File 'lib/gitlab/import_export/shared.rb', line 26

def logger
  @logger
end

Instance Method Details

#active_export_countObject


36
37
38
# File 'lib/gitlab/import_export/shared.rb', line 36

def active_export_count
  Dir[File.join(base_path, '*')].count { |name| File.basename(name) != LOCKS_DIRECTORY && File.directory?(name) }
end

#add_error_message(message) ⇒ Object


64
65
66
# File 'lib/gitlab/import_export/shared.rb', line 64

def add_error_message(message)
  @errors << filtered_error_message(message)
end

#after_export_in_progress?Boolean

Returns:

  • (Boolean)

68
69
70
# File 'lib/gitlab/import_export/shared.rb', line 68

def after_export_in_progress?
  locks_present?
end

#archive_pathObject

The path where the tarball is saved


46
47
48
# File 'lib/gitlab/import_export/shared.rb', line 46

def archive_path
  @archive_path ||= Gitlab::ImportExport.export_path(relative_path: relative_archive_path)
end

#base_pathObject


50
51
52
# File 'lib/gitlab/import_export/shared.rb', line 50

def base_path
  @base_path ||= Gitlab::ImportExport.export_path(relative_path: relative_base_path)
end

#error(error) ⇒ Object


58
59
60
61
62
# File 'lib/gitlab/import_export/shared.rb', line 58

def error(error)
  Gitlab::ErrorTracking.track_exception(error, log_base_data)

  add_error_message(error.message)
end

#export_pathObject

The path where the exportable metadata and repository bundle (in case of project) is saved


41
42
43
# File 'lib/gitlab/import_export/shared.rb', line 41

def export_path
  @export_path ||= Gitlab::ImportExport.export_path(relative_path: relative_path)
end

#lock_files_pathObject


54
55
56
# File 'lib/gitlab/import_export/shared.rb', line 54

def lock_files_path
  @locks_files_path ||= File.join(base_path, LOCKS_DIRECTORY)
end

#locks_present?Boolean

Returns:

  • (Boolean)

72
73
74
# File 'lib/gitlab/import_export/shared.rb', line 72

def locks_present?
  Dir.exist?(lock_files_path) && !Dir.empty?(lock_files_path)
end