#8 Use http code to check object in lookaside cache
Merged a month ago by arrfab. Opened a month ago by amoralej.
amoralej/centos-git-common master  into  master

file modified
+2 -1

@@ -80,8 +80,9 @@ 

  

  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

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.

LGTM, merging. Thanks !

Pull-Request has been merged by arrfab

a month ago
Metadata