Commit 7c9f2168 authored by James Lopez's avatar James Lopez

add restore method

parent a27d4d9e
......@@ -16,7 +16,7 @@ module Gitlab
shared: @shared,
relative_export_path: 'avatar',
from: avatar_path
).copy
).save
rescue => e
@shared.error(e)
false
......
......@@ -10,8 +10,8 @@ module Gitlab
@from = from || default_uploads_path
end
def copy
copy_files(@from, uploads_export_path) if File.directory?(@from)
def save
copy_files(@from, default_uploads_path) if File.directory?(@from)
if File.file?(@from) && @relative_export_path == 'avatar'
copy_files(@from, File.join(uploads_export_path, @project.avatar.filename))
......@@ -25,6 +25,21 @@ module Gitlab
false
end
def restore
Dir["#{uploads_export_path}/**/*"].each do |upload|
next if File.directory?(upload)
upload_path = File.join(uploads_export_path, upload)
UploadService.new(@project, File.open(upload_path, 'r'), FileUploader).execute
end
true
rescue => e
@shared.error(e)
false
end
private
def copy_from_object_storage
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment