Skip to content
Snippets Groups Projects
Commit 214486a5 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Uploads files to the DAV server with a check

parent 4b9b2d78
No related branches found
No related tags found
No related merge requests found
...@@ -119,6 +119,14 @@ run_cmd() { ...@@ -119,6 +119,14 @@ run_cmd() {
} }
# Checks if a file exists on the remote location
# $1: Path to the file to check on the server
dav_exists() {
curl --head --silent --location ${DOCSERVER}/${1} | grep HTTP | tail -n 1 | grep -q 200
return $?
}
# Uploads a file to our intranet location via curl # Uploads a file to our intranet location via curl
# $1: Path to the file to upload (e.g. dist/myfile.whl) # $1: Path to the file to upload (e.g. dist/myfile.whl)
# $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/) # $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/)
...@@ -139,6 +147,20 @@ dav_upload() { ...@@ -139,6 +147,20 @@ dav_upload() {
} }
# Uploads a file to our intranet location via curl, if (and only if) it does
# not exist on the remote server
# $1: Path to the file to upload (e.g. dist/myfile.whl)
# $2: Path on the server to upload to (e.g. private-upload/wheels/gitlab/)
dav_check_upload() {
local remote_name=${2}/$(basename ${1})
if dav_exists ${remote_name}; then
log_info "File \`${remote_name}' already exists on the remote server (not uploading again)"
else
dav_upload ${1} ${2}
fi
}
# Creates a folder at our intranet location via curl # Creates a folder at our intranet location via curl
# $1: Path of the folder to create (e.g. private-upload/docs/test-folder) # $1: Path of the folder to create (e.g. private-upload/docs/test-folder)
# $2: which HTTP response code it should return instead of exit on (e.g. 405 means the folder already exists) # $2: which HTTP response code it should return instead of exit on (e.g. 405 means the folder already exists)
...@@ -244,17 +266,6 @@ dav_upload_folder() { ...@@ -244,17 +266,6 @@ dav_upload_folder() {
} }
# Checks if an array contains a value
# taken from here: https://stackoverflow.com/questions/3685970/check-if-an-array-contains-a-value
# Parameters: <value-to-check> <array-variable>
# Usage: "a string" "${array[@]}"
contains_element () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
if [ -z "${BOB_PACKAGE_VERSION}" ]; then if [ -z "${BOB_PACKAGE_VERSION}" ]; then
if [ ! -r "version.txt" ]; then if [ ! -r "version.txt" ]; then
log_error "./version.txt does not exist - cannot figure out version number" log_error "./version.txt does not exist - cannot figure out version number"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment