Commit 2c1e66d4 authored by James Lopez's avatar James Lopez

Fix avatar saver and spec

parent 874a4ff1
...@@ -11,7 +11,12 @@ module Gitlab ...@@ -11,7 +11,12 @@ module Gitlab
def save def save
return true unless @project.avatar.exists? return true unless @project.avatar.exists?
copy_files(avatar_path, avatar_export_path) Gitlab::ImportExport::UploadsManager.new(
project: @project,
shared: @shared,
relative_export_path: 'avatar',
from: avatar_path
).copy
rescue => e rescue => e
@shared.error(e) @shared.error(e)
false false
...@@ -19,10 +24,6 @@ module Gitlab ...@@ -19,10 +24,6 @@ module Gitlab
private private
def avatar_export_path
File.join(@shared.export_path, 'avatar', @project.avatar_identifier)
end
def avatar_path def avatar_path
@project.avatar.path @project.avatar.path
end end
......
...@@ -9,6 +9,7 @@ describe Gitlab::ImportExport::AvatarSaver do ...@@ -9,6 +9,7 @@ describe Gitlab::ImportExport::AvatarSaver do
before do before do
FileUtils.mkdir_p("#{shared.export_path}/avatar/") FileUtils.mkdir_p("#{shared.export_path}/avatar/")
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
stub_feature_flags(import_export_object_storage: false)
end end
after do after do
...@@ -18,6 +19,8 @@ describe Gitlab::ImportExport::AvatarSaver do ...@@ -18,6 +19,8 @@ describe Gitlab::ImportExport::AvatarSaver do
it 'saves a project avatar' do it 'saves a project avatar' do
described_class.new(project: project_with_avatar, shared: shared).save described_class.new(project: project_with_avatar, shared: shared).save
puts "#{shared.export_path}/avatar/dk.png"
expect(File).to exist("#{shared.export_path}/avatar/dk.png") expect(File).to exist("#{shared.export_path}/avatar/dk.png")
end end
......
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