From b192580204504b629c64522dcb5061c3a82b5c80 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Fri, 23 Jun 2017 13:46:53 +0200 Subject: [PATCH] Check if directory/file exists on disk before trying a dav_upload --- gitlab/functions.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gitlab/functions.sh b/gitlab/functions.sh index 6dabe0e..c173d42 100644 --- a/gitlab/functions.sh +++ b/gitlab/functions.sh @@ -193,6 +193,12 @@ setup_deploy() { # $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/) dav_upload() { log_info "curl: ${1} -> ${DOCSERVER}/${2}..." + + if [ ! -e $1 ]; then + log_error "File \`${1}\' does not exist on the local disk" + exit 1 + fi + local code=`curl --location --silent --fail --write-out "%{http_code}" --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2}` if [[ ${code} == *204 || ${code} == *201 ]]; then log_info "Successfully uploaded ${1} with curl" @@ -252,6 +258,11 @@ dav_delete() { dav_upload_folder() { log_info "curl: ${1} -> ${DOCSERVER}/${2}..." + if [ ! -e $1 ]; then + log_error "Directory \`${1}\' does not exist on the local disk" + exit 1 + fi + find "$1" | while read -r fname; do # make sure the location has at least 1 '/' at the end # more than 1 '/' together (e.g. '//') is interpreted as 1 '/' -- GitLab