gitlab-org--gitlab-foss/lib/gitlab/import_export/uploads_saver.rb
James Lopez 76771c2946 squashed - added avatar saver/restorer and specs
added spec for avatar saver

avatar saver!

added avatar restorer spec

fix spec

added avatar restorer class

fix export service

fix warnings, added changelog

fix spec

some refactoring based on feedback

fixed a few issues after testing i/e avatar
2016-07-19 13:06:06 +02:00

31 lines
650 B
Ruby

module Gitlab
module ImportExport
class UploadsSaver
include Gitlab::ImportExport::CommandLineUtil
def initialize(project:, shared:)
@project = project
@shared = shared
end
def save
return true unless File.directory?(uploads_path)
copy_files(uploads_path, uploads_export_path)
rescue => e
@shared.error(e)
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