diff options
author | James Lopez <james@jameslopez.es> | 2018-07-10 17:33:40 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2018-07-10 17:33:40 +0300 |
commit | a27d4d9e524ee0b7eb5f5518fc6f8af00e1e6dfe (patch) | |
tree | c9c7f03cf5b5ecb0fc7f027daebab109aa76c417 /lib/gitlab/import_export | |
parent | 2c1e66d4d2124ec3d6101a6c5586867139f6fd20 (diff) |
update uploads saver
Diffstat (limited to 'lib/gitlab/import_export')
-rw-r--r-- | lib/gitlab/import_export/uploads_manager.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/import_export/uploads_saver.rb | 15 |
2 files changed, 16 insertions, 13 deletions
diff --git a/lib/gitlab/import_export/uploads_manager.rb b/lib/gitlab/import_export/uploads_manager.rb index 2992c81b731..63935fc6822 100644 --- a/lib/gitlab/import_export/uploads_manager.rb +++ b/lib/gitlab/import_export/uploads_manager.rb @@ -13,7 +13,16 @@ module Gitlab def copy 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)) + end + copy_from_object_storage + + true + rescue => e + @shared.error(e) + false end private @@ -49,9 +58,10 @@ module Gitlab end def download_and_copy(upload) - mkdir_p(File.join(uploads_export_path, upload.secret)) + secret = upload.try(:secret) || '' + upload_path = File.join(uploads_export_path, secret, upload.filename) - upload_path = File.join(uploads_export_path, upload.secret, upload.filename) + mkdir_p(File.join(uploads_export_path, secret)) File.open(upload_path, 'w') do |file| IO.copy_stream(URI.parse(upload.file.url).open, file) diff --git a/lib/gitlab/import_export/uploads_saver.rb b/lib/gitlab/import_export/uploads_saver.rb index 2f08dda55fd..9cdd015d82a 100644 --- a/lib/gitlab/import_export/uploads_saver.rb +++ b/lib/gitlab/import_export/uploads_saver.rb @@ -9,21 +9,14 @@ module Gitlab end def save - return true unless File.directory?(uploads_path) - - copy_files(uploads_path, uploads_export_path) + Gitlab::ImportExport::UploadsManager.new( + project: @project, + shared: @shared, + ).copy rescue => e @shared.error(e) false end - - def uploads_path - FileUploader.absolute_base_dir(@project) - end - - def uploads_export_path - File.join(@shared.export_path, 'uploads') - end end end end |