gitlab-org--gitlab-foss/lib/gitlab/import_export/uploads_saver.rb

36 lines
691 B
Ruby
Raw Normal View History

2016-05-19 11:02:57 +00:00
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
2016-05-19 11:21:56 +00:00
File.join(Rails.root.join('public/uploads'), @project.path_with_namespace)
2016-05-19 11:02:57 +00:00
end
end
end
end