Commit b287e425 authored by Stan Hu's avatar Stan Hu

Merge branch 'mk/geo/fix-error-during-failed-download' into 'master'

Fix `NULL` insert attempts for `missing_on_primary`

Closes #5727

See merge request gitlab-org/gitlab-ee!5428
parents 997407d5 2f6a1e19
......@@ -106,10 +106,13 @@ module Gitlab
body = File.read(temp_file.path) if File.exist?(temp_file.path)
if response.code == 404 && body.present?
json_response = JSON.parse(body)
json_response['geo_code'] == Gitlab::Geo::FileUploader::FILE_NOT_FOUND_GEO_CODE
begin
json_response = JSON.parse(body)
return json_response['geo_code'] == Gitlab::Geo::FileUploader::FILE_NOT_FOUND_GEO_CODE
rescue JSON::ParserError
end
end
rescue JSON::ParserError
false
end
......
......@@ -71,7 +71,7 @@ describe Gitlab::Geo::Transfer do
result = subject.download_from_primary
expect_result(result, success: false, bytes_downloaded: 0)
expect_result(result, success: false, bytes_downloaded: 0, primary_missing_file: false)
end
end
end
......@@ -102,9 +102,13 @@ describe Gitlab::Geo::Transfer do
end
end
def expect_result(result, success:, bytes_downloaded:, primary_missing_file: nil)
def expect_result(result, success:, bytes_downloaded:, primary_missing_file:)
expect(result.success).to eq(success)
expect(result.bytes_downloaded).to eq(bytes_downloaded)
expect(result.primary_missing_file).to eq(primary_missing_file)
# Sanity check to help ensure a valid test
expect(success).not_to be_nil
expect(primary_missing_file).not_to be_nil
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