adding versioning to export
This commit is contained in:
parent
f386d7a7b7
commit
5777ad9a1f
3 changed files with 43 additions and 3 deletions
|
@ -4,12 +4,16 @@ module Projects
|
|||
|
||||
def execute(options = {})
|
||||
@shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.path_with_namespace, 'work'))
|
||||
save_all if [save_project_tree, bundle_repo, bundle_wiki_repo].all?
|
||||
notify_worker if @shared.errors.any?
|
||||
save_all if [save_version, save_project_tree, bundle_repo, bundle_wiki_repo].all?
|
||||
cleanup_and_notify_worker if @shared.errors.any?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def save_version
|
||||
Gitlab::ImportExport::VersionSaver.save(shared: @shared)
|
||||
end
|
||||
|
||||
def save_project_tree
|
||||
Gitlab::ImportExport::ProjectTreeSaver.new(project: project, shared: @shared).save
|
||||
end
|
||||
|
@ -26,7 +30,8 @@ module Projects
|
|||
Gitlab::ImportExport::Saver.save(shared: @shared)
|
||||
end
|
||||
|
||||
def notify_worker
|
||||
def cleanup_and_notify_worker
|
||||
FileUtils.rm_rf(@shared.export_path)
|
||||
raise Gitlab::ImportExport::Error.new(@shared.errors.join(', '))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ module Gitlab
|
|||
module ImportExport
|
||||
extend self
|
||||
|
||||
VERSION = '0.1.0'
|
||||
|
||||
def export_path(relative_path:)
|
||||
File.join(storage_path, relative_path)
|
||||
end
|
||||
|
@ -17,5 +19,9 @@ module Gitlab
|
|||
def project_bundle_filename
|
||||
"project.bundle"
|
||||
end
|
||||
|
||||
def version_filename
|
||||
'VERSION'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
29
lib/gitlab/import_export/version_saver.rb
Normal file
29
lib/gitlab/import_export/version_saver.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Gitlab
|
||||
module ImportExport
|
||||
class VersionSaver
|
||||
|
||||
def self.save(*args)
|
||||
new(*args).save
|
||||
end
|
||||
|
||||
def initialize(shared:)
|
||||
@shared = shared
|
||||
end
|
||||
|
||||
def save
|
||||
File.open(version_file, 'w') do |file|
|
||||
file.write(Gitlab::ImportExport.VERSION)
|
||||
end
|
||||
rescue => e
|
||||
@shared.error(e.message)
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def version_file
|
||||
File.join(@shared.export_path, Gitlab::ImportExport.version_filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue