From e6e12ecbfde9112e573cab56cccd5f427fa6f9ef Mon Sep 17 00:00:00 2001 From: Fabian Arrotin Date: May 29 2020 16:00:58 +0000 Subject: Cosmetic change for lookaside_upload and better curl return code check Signed-off-by: Fabian Arrotin --- diff --git a/lookaside_upload b/lookaside_upload index e971af9..e42f3ec 100755 --- a/lookaside_upload +++ b/lookaside_upload @@ -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