From 510f1aa0bcab5caedc4771ff2dc2319b22b446e0 Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Oct 26 2021 08:17:32 +0000 Subject: 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. --- diff --git a/lookaside_upload b/lookaside_upload index 4c5612a..05dfae4 100755 --- a/lookaside_upload +++ b/lookaside_upload @@ -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