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

add restore method

parent a27d4d9e
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
shared: @shared, shared: @shared,
relative_export_path: 'avatar', relative_export_path: 'avatar',
from: avatar_path from: avatar_path
).copy ).save
rescue => e rescue => e
@shared.error(e) @shared.error(e)
false false
......
...@@ -10,8 +10,8 @@ module Gitlab ...@@ -10,8 +10,8 @@ module Gitlab
@from = from || default_uploads_path @from = from || default_uploads_path
end end
def copy def save
copy_files(@from, uploads_export_path) if File.directory?(@from) copy_files(@from, default_uploads_path) if File.directory?(@from)
if File.file?(@from) && @relative_export_path == 'avatar' if File.file?(@from) && @relative_export_path == 'avatar'
copy_files(@from, File.join(uploads_export_path, @project.avatar.filename)) copy_files(@from, File.join(uploads_export_path, @project.avatar.filename))
...@@ -25,6 +25,21 @@ module Gitlab ...@@ -25,6 +25,21 @@ module Gitlab
false false
end 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 private
def copy_from_object_storage 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