Class: Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy
show all
- Extended by:
- Forwardable, CommandLineUtil
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
Constant Summary
collapse
- StrategyError =
Class.new(StandardError)
CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, CommandLineUtil::CommandLineUtilError, CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, CommandLineUtil::HardLinkError, CommandLineUtil::UNTAR_MASK
Instance Method Summary
collapse
gunzip, gzip, gzip_with_options, mkdir_p, tar_cf, tar_czf, untar_xf, untar_zxf
Constructor Details
Returns a new instance of BaseAfterExportStrategy.
19
20
21
22
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 19
def initialize(attributes = {})
@options = attributes
@logger = Gitlab::Export::Logger.build
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
24
25
26
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 24
def method_missing(method, *args)
@options[method]
end
|
Instance Method Details
#archive_path ⇒ Object
75
76
77
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 75
def archive_path
project.import_export_shared.archive_path
end
|
#ensure_export_ready!(current_user) ⇒ Object
63
64
65
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 63
def ensure_export_ready!(current_user)
raise StrategyError unless project.export_file_exists?(current_user)
end
|
#ensure_lock_files_path! ⇒ Object
67
68
69
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 67
def ensure_lock_files_path!
FileUtils.mkdir_p(lock_files_path) unless Dir.exist?(lock_files_path)
end
|
#execute(current_user, project) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 28
def execute(current_user, project)
@project = project
ensure_export_ready!(current_user)
ensure_lock_files_path!
@lock_file = File.join(lock_files_path, SecureRandom.hex)
@current_user = current_user
if invalid?
log_validation_errors
return
end
create_or_update_after_export_lock
strategy_execute
true
rescue StandardError => e
payload = { message: "After export strategy failed" }
Gitlab::ExceptionLogFormatter.format!(e, payload)
log_error(payload)
project.import_export_shared.error(e)
false
ensure
delete_after_export_lock
delete_export_file(current_user)
delete_archive_path
end
|
#lock_files_path ⇒ Object
71
72
73
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 71
def lock_files_path
project.import_export_shared.lock_files_path
end
|
#locks_present? ⇒ Boolean
79
80
81
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 79
def locks_present?
project.import_export_shared.locks_present?
end
|
#to_json(options = {}) ⇒ Object
59
60
61
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 59
def to_json(options = {})
@options.to_h.merge!(klass: self.class.name).to_json
end
|