Merge #3 Check file existence before upload

This commit is contained in:
Fabian Arrotin 2019-04-11 17:33:50 +00:00
commit eeff201b83

View file

@ -71,8 +71,28 @@ if [ ! -f ~/.centos.cert ] ;then
exit 1
fi
f_log "Initialing new upload to lookaside"
if [ ! -f "${file}" ] ;then
f_log "Source to upload ${file} not found"
exit 2
fi
checksum=$(sha1sum ${file}|awk '{print $1}')
f_log "Checking if file already uploaded"
result=$(curl ${lookaside_baseurl}/sources/upload.cgi \
--fail \
-s \
--cert ~/.centos.cert \
--form "name=${pkgname}" \
--form "branch=${branch}" \
--form "sha1sum=${checksum}")
if [ "$result" = "Available" ] ;then
f_log "File already uploaded"
exit 3
fi
f_log "Initialing new upload to lookaside"
f_log "URL : $lookaside_baseurl"
f_log "Source to upload : ${file} "
f_log "Package name: $pkgname"