Cosmetic change for lookaside_upload and better curl return code check

Signed-off-by: Fabian Arrotin <arrfab@centos.org>
This commit is contained in:
Fabian Arrotin 2020-05-29 18:00:58 +02:00
parent c43fda67c5
commit e6e12ecbfd

View file

@ -109,14 +109,21 @@ curl ${lookaside_baseurl}/sources/upload.cgi \
--form "file=@${file}" \
--progress-bar | tee /dev/null
f_log "Returned value: $?"
upload_result="${PIPESTATUS[0]}"
if [ "$upload_result" -ne "0" ] ;then
f_log "[ERROR] Something didn't work to push to ${lookaside_baseurl}/sources/${pkgname}/${branch}/${checksum}"
f_log "[ERROR] Verify at the server side"
exit 1
fi
f_log "Validating that source was correctly uploaded ...."
local_size=$(stat -c %s ${file})
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
f_log "Source should be available at ${lookaside_baseurl}/sources/${pkgname}/${branch}/${checksum}"
f_log "[SUCCESS] Source should be available at ${lookaside_baseurl}/sources/${pkgname}/${branch}/${checksum}"
else
f_log "ERROR : it seems there is a mismatch with source size and remote file size"
f_log "[ERROR] it seems there is a mismatch with source size and remote file size"
fi