summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2018-07-11 11:36:59 +0200
committerJames Lopez <james@jameslopez.es>2018-07-11 11:36:59 +0200
commit3a114c2d119a9d0a7a8a9c85a6c7ec405f3a0f12 (patch)
tree6abb5e663805b9c5c0bfc0509f5cbf5809e92ef3 /lib
parent7c9f21683ce2eea8f1f901d81b32ad775d7f9ba6 (diff)
downloadgitlab-ce-3a114c2d119a9d0a7a8a9c85a6c7ec405f3a0f12.tar.gz
fix specs
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/import_export/uploads_manager.rb6
-rw-r--r--lib/gitlab/import_export/uploads_restorer.rb13
-rw-r--r--lib/gitlab/import_export/uploads_saver.rb4
3 files changed, 14 insertions, 9 deletions
diff --git a/lib/gitlab/import_export/uploads_manager.rb b/lib/gitlab/import_export/uploads_manager.rb
index d47b1f2e8f7..c968deb6b19 100644
--- a/lib/gitlab/import_export/uploads_manager.rb
+++ b/lib/gitlab/import_export/uploads_manager.rb
@@ -11,7 +11,7 @@ module Gitlab
end
def save
- copy_files(@from, default_uploads_path) if File.directory?(@from)
+ copy_files(@from, uploads_export_path) if File.directory?(@from)
if File.file?(@from) && @relative_export_path == 'avatar'
copy_files(@from, File.join(uploads_export_path, @project.avatar.filename))
@@ -29,9 +29,7 @@ module Gitlab
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
+ UploadService.new(@project, File.open(upload, 'r'), FileUploader).execute
end
true
diff --git a/lib/gitlab/import_export/uploads_restorer.rb b/lib/gitlab/import_export/uploads_restorer.rb
index df19354b76e..b7e07fc1226 100644
--- a/lib/gitlab/import_export/uploads_restorer.rb
+++ b/lib/gitlab/import_export/uploads_restorer.rb
@@ -2,9 +2,16 @@ module Gitlab
module ImportExport
class UploadsRestorer < UploadsSaver
def restore
- return true unless File.directory?(uploads_export_path)
-
- copy_files(uploads_export_path, uploads_path)
+ 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)
+ else
+ true
+ end
rescue => e
@shared.error(e)
false
diff --git a/lib/gitlab/import_export/uploads_saver.rb b/lib/gitlab/import_export/uploads_saver.rb
index 9cdd015d82a..b3f17af5661 100644
--- a/lib/gitlab/import_export/uploads_saver.rb
+++ b/lib/gitlab/import_export/uploads_saver.rb
@@ -11,8 +11,8 @@ module Gitlab
def save
Gitlab::ImportExport::UploadsManager.new(
project: @project,
- shared: @shared,
- ).copy
+ shared: @shared
+ ).save
rescue => e
@shared.error(e)
false