Handle the case of a PUT on a non-existing object

The previous code was returning a 500 because the HEAD request failed
This commit is contained in:
Greg Karékinian 2018-01-05 13:11:47 +01:00
parent 2fac808343
commit 3ddcccaee7

View File

@ -147,7 +147,12 @@ module RemoteStorage
unless required_match == %Q("#{existing_metadata["e"]}")
# get actual metadata and compare in case redis metadata became out of sync
head_res = do_head_request(url)
begin
head_res = do_head_request(url)
# The file doesn't exist in Orbit, return 412
rescue RestClient::ResourceNotFound
server.halt 412, "Precondition Failed"
end
if required_match == %Q("#{head_res.headers[:etag]}")
# log previous size difference that was missed ealier because of redis failure