Commit 788bd40d authored by Nick Thomas's avatar Nick Thomas

Merge branch...

Merge branch '5335-undefined-method-log_transfer_error-for-gitlab-geo-jobartifacttransfer-0x00007fea0ac401e8' into 'master'

Resolve "undefined method `log_transfer_error' for #<Gitlab::Geo::JobArtifactTransfer:0x00007fea0ac401e8>"

See merge request gitlab-org/gitlab-ee!5018
parents ab983d47 e6223bae
---
title: Resolve "undefined method 'log_transfer_error'"
merge_request:
author:
type: fixed
...@@ -39,15 +39,10 @@ module Gitlab ...@@ -39,15 +39,10 @@ module Gitlab
return true if File.directory?(dir) 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 begin
FileUtils.mkdir_p(dir) FileUtils.mkdir_p(dir)
rescue => e rescue => e
log_transfer_error("unable to create directory #{dir}: #{e}") log_error("unable to create directory #{dir}: #{e}")
return false return false
end end
......
...@@ -6,6 +6,7 @@ describe Gitlab::Geo::Transfer do ...@@ -6,6 +6,7 @@ describe Gitlab::Geo::Transfer do
set(:primary_node) { create(:geo_node, :primary) } set(:primary_node) { create(:geo_node, :primary) }
set(:secondary_node) { create(:geo_node) } set(:secondary_node) { create(:geo_node) }
set(:lfs_object) { create(:lfs_object, :with_file) } 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(:url) { primary_node.geo_transfers_url(:lfs, lfs_object.id.to_s) }
let(:content) { SecureRandom.random_bytes(10) } let(:content) { SecureRandom.random_bytes(10) }
let(:size) { File.stat(lfs_object.file.path).size } let(:size) { File.stat(lfs_object.file.path).size }
...@@ -13,7 +14,7 @@ describe Gitlab::Geo::Transfer do ...@@ -13,7 +14,7 @@ describe Gitlab::Geo::Transfer do
subject do subject do
described_class.new(:lfs, described_class.new(:lfs,
lfs_object.id, lfs_object.id,
lfs_object.file.path, lfs_object_file_path,
{ sha256: lfs_object.oid }) { sha256: lfs_object.oid })
end end
...@@ -53,5 +54,16 @@ describe Gitlab::Geo::Transfer do ...@@ -53,5 +54,16 @@ describe Gitlab::Geo::Transfer do
expect(subject.download_from_primary).to eq(nil) expect(subject.download_from_primary).to eq(nil)
end 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
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