2016-05-19 13:36:20 +00:00
|
|
|
module Gitlab
|
|
|
|
module ImportExport
|
|
|
|
class UploadsRestorer < UploadsSaver
|
2016-06-13 11:34:36 +00:00
|
|
|
def restore
|
2018-07-11 09:36:59 +00:00
|
|
|
if Gitlab::ImportExport.object_storage?
|
|
|
|
Gitlab::ImportExport::UploadsManager.new(
|
|
|
|
project: @project,
|
|
|
|
shared: @shared
|
|
|
|
).restore
|
|
|
|
elsif File.directory?(uploads_export_path)
|
|
|
|
copy_files(uploads_export_path, uploads_path)
|
2018-07-11 13:58:42 +00:00
|
|
|
|
|
|
|
true
|
2018-07-11 09:36:59 +00:00
|
|
|
else
|
2018-07-16 09:45:11 +00:00
|
|
|
true # Proceed without uploads
|
2018-07-11 09:36:59 +00:00
|
|
|
end
|
2016-05-19 13:36:20 +00:00
|
|
|
rescue => e
|
|
|
|
@shared.error(e)
|
|
|
|
false
|
|
|
|
end
|
2018-07-11 10:02:01 +00:00
|
|
|
|
|
|
|
def uploads_path
|
|
|
|
FileUploader.absolute_base_dir(@project)
|
|
|
|
end
|
2018-07-12 06:46:24 +00:00
|
|
|
|
|
|
|
def uploads_export_path
|
|
|
|
@uploads_export_path ||= File.join(@shared.export_path, 'uploads')
|
|
|
|
end
|
2016-05-19 13:36:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|