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::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, 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
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 19
def initialize(attributes = {})
@options = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
23
24
25
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 23
def method_missing(method, *args)
@options[method]
end
|
Instance Method Details
#archive_path ⇒ Object
70
71
72
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 70
def archive_path
project.import_export_shared.archive_path
end
|
#ensure_export_ready! ⇒ Object
58
59
60
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 58
def ensure_export_ready!
raise StrategyError unless project.export_file_exists?
end
|
#ensure_lock_files_path! ⇒ Object
62
63
64
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 62
def ensure_lock_files_path!
FileUtils.mkdir_p(lock_files_path) unless Dir.exist?(lock_files_path)
end
|
#execute(current_user, project) ⇒ Object
27
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
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 27
def execute(current_user, project)
@project = project
ensure_export_ready!
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
project.import_export_shared.error(e)
false
ensure
delete_after_export_lock
delete_export_file
delete_archive_path
end
|
#lock_files_path ⇒ Object
66
67
68
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 66
def lock_files_path
project.import_export_shared.lock_files_path
end
|
#locks_present? ⇒ Boolean
74
75
76
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 74
def locks_present?
project.import_export_shared.locks_present?
end
|
#to_json(options = {}) ⇒ Object
54
55
56
|
# File 'lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb', line 54
def to_json(options = {})
@options.to_h.merge!(klass: self.class.name).to_json
end
|