Commit 89675a1a authored by Catalin Irimie's avatar Catalin Irimie

Fix Geo checksummable check failing when file is nil

In specific cases, such as the LFS download flow,
we would first create a model before updating it to contain
a file as well, which means it's possible the model's file
doesn't exist.

We have an after_commit hook that attempts to verify if
a record's file is checksummable to run verification on,
however this would have failed if the file was nil before this.

Changelog: fixed
EE: true
parent 115beffe
......@@ -95,7 +95,7 @@ module Geo
#
# @return [Boolean] whether the file exists on disk or in remote storage
def file_exists?
carrierwave_uploader.file.exists?
carrierwave_uploader.file&.exists?
end
def deleted_params
......
......@@ -231,4 +231,29 @@ RSpec.shared_examples 'a blob replicator' do
end
end
end
describe '#file_exists?' do
let(:file) { double(exists?: true) }
let(:uploader) { double(file: file) }
subject { replicator.file_exists? }
before do
allow(replicator).to receive(:carrierwave_uploader).and_return(uploader)
end
it { is_expected.to be_truthy }
context 'when the file does not exist' do
let(:file) { double(exists?: false) }
it { is_expected.to be_falsey }
end
context 'when the file is nil' do
let(:file) { nil }
it { is_expected.to be_falsey }
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