Commit e6223bae authored by Valery Sizov's avatar Valery Sizov

Fix undefined method `log_transfer_error'

parent 51aff7ab
---
title: Resolve "undefined method 'log_transfer_error'"
merge_request:
author:
type: fixed
......@@ -39,15 +39,10 @@ module Gitlab
return true if File.directory?(dir)
if File.exist?(dir)
log_transfer_error("#{dir} is not a directory, unable to save #{filename}")
return false
end
begin
FileUtils.mkdir_p(dir)
rescue => e
log_transfer_error("unable to create directory #{dir}: #{e}")
log_error("unable to create directory #{dir}: #{e}")
return false
end
......
......@@ -6,6 +6,7 @@ describe Gitlab::Geo::Transfer do
set(:primary_node) { create(:geo_node, :primary) }
set(:secondary_node) { create(:geo_node) }
set(:lfs_object) { create(:lfs_object, :with_file) }
let(:lfs_object_file_path) { lfs_object.file.path }
let(:url) { primary_node.geo_transfers_url(:lfs, lfs_object.id.to_s) }
let(:content) { SecureRandom.random_bytes(10) }
let(:size) { File.stat(lfs_object.file.path).size }
......@@ -13,7 +14,7 @@ describe Gitlab::Geo::Transfer do
subject do
described_class.new(:lfs,
lfs_object.id,
lfs_object.file.path,
lfs_object_file_path,
{ sha256: lfs_object.oid })
end
......@@ -53,5 +54,16 @@ describe Gitlab::Geo::Transfer do
expect(subject.download_from_primary).to eq(nil)
end
context "invalid path" do
let(:lfs_object_file_path) { '/foo/bar' }
it 'logs an error if the destination directory could not be created' do
allow(FileUtils).to receive(:mkdir_p) { raise Errno::EEXIST }
expect(subject).to receive(:log_error).with("unable to create directory /foo: File exists")
expect(subject.download_from_primary).to be_nil
end
end
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