uploads export
This commit is contained in:
parent
a5f04ad488
commit
30f4dcd4c9
2 changed files with 40 additions and 1 deletions
|
@ -4,7 +4,7 @@ module Projects
|
||||||
|
|
||||||
def execute(options = {})
|
def execute(options = {})
|
||||||
@shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.path_with_namespace, 'work'))
|
@shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.path_with_namespace, 'work'))
|
||||||
save_all if [save_version, save_project_tree, bundle_repo, bundle_wiki_repo].all?
|
save_all if [save_version, save_project_tree, save_uploads, bundle_repo, bundle_wiki_repo].all?
|
||||||
cleanup_and_notify_worker if @shared.errors.any?
|
cleanup_and_notify_worker if @shared.errors.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ module Projects
|
||||||
Gitlab::ImportExport::ProjectTreeSaver.new(project: project, shared: @shared).save
|
Gitlab::ImportExport::ProjectTreeSaver.new(project: project, shared: @shared).save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_uploads
|
||||||
|
Gitlab::ImportExport::UploadsSaver.save(project: project, shared: @shared)
|
||||||
|
end
|
||||||
|
|
||||||
def bundle_repo
|
def bundle_repo
|
||||||
Gitlab::ImportExport::RepoBundler.new(project: project, shared: @shared).bundle
|
Gitlab::ImportExport::RepoBundler.new(project: project, shared: @shared).bundle
|
||||||
end
|
end
|
||||||
|
|
35
lib/gitlab/import_export/uploads_saver.rb
Normal file
35
lib/gitlab/import_export/uploads_saver.rb
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
module Gitlab
|
||||||
|
module ImportExport
|
||||||
|
class UploadsSaver
|
||||||
|
|
||||||
|
def self.save(*args)
|
||||||
|
new(*args).save
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(project:, shared:)
|
||||||
|
@project = project
|
||||||
|
@shared = shared
|
||||||
|
end
|
||||||
|
|
||||||
|
def save
|
||||||
|
return true unless File.directory?(uploads_path)
|
||||||
|
|
||||||
|
FileUtils.copy_entry(uploads_path, uploads_export_path)
|
||||||
|
true
|
||||||
|
rescue => e
|
||||||
|
@shared.error(e.message)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def uploads_export_path
|
||||||
|
File.join(@shared.export_path, 'uploads')
|
||||||
|
end
|
||||||
|
|
||||||
|
def uploads_path
|
||||||
|
File.join(Rails.root.join('public/uploads'), project.path_with_namespace)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue