mirror of
https://git.centos.org/centos-git-common.git
synced 2025-02-23 08:12:56 +00:00
Use http code to check object in lookaside cache
Currently, it only checks the size of the http object returned but it may happen that the size of the 404 error page match the size of the tarball. You may think this is a corner case we'll never hit... well, we hit it, :) This patch it's adding a check based on the http code, so to give it as already uploaded we need it to return 200 code and match the actual size.
This commit is contained in:
parent
b045956f51
commit
510f1aa0bc
1 changed files with 2 additions and 1 deletions
|
@ -80,8 +80,9 @@ checksum=$(sha1sum ${file}|awk '{print $1}')
|
|||
|
||||
f_log "Checking if file already uploaded"
|
||||
local_size=$(stat -c %s ${file})
|
||||
http_code=$(curl -s -o /dev/null -w "%{http_code}" ${lookaside_baseurl}/sources/${pkgname}/${branch}/${checksum})
|
||||
remote_size=$(curl --silent -i --head ${lookaside_baseurl}/sources/${pkgname}/${branch}/${checksum}|grep "Content-Length"|cut -f 2 -d ':'|tr -d [:blank:]|tr -d '\r')
|
||||
if [ "$local_size" -eq "$remote_size" ] ; then
|
||||
if [ "$http_code" -eq 200 ] && [ "$local_size" -eq "$remote_size" ] ; then
|
||||
f_log "File already uploaded"
|
||||
exit 3
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue