diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index 742510770459864dbdfcf2e73f576415a9873b01..155d887836b105e22c201e2f3adb5afcae7a0a51 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -147,11 +147,12 @@ dav_mkdir() {
 
   if [[ ${code} == *204 || ${code} == *201 ]]; then
     log_info "curl: mkdir ${DOCSERVER}/${1}"
-  # if the return code was not a success, the function should usually treat it as an error.
-  # however, sometimes the codes must be treated more flexibly, e.g.:
-  # dav_recursive_mkdir wants the directory created *or* already existing,
-  # which means that a 405 (directory already exists) should not be treated as an error.
-  # other codes may also have similar consideration in the future.
+  # if the return code was not a success, the function should usually treat it
+  # as an error.  however, sometimes the codes must be treated more flexibly,
+  # e.g.: dav_recursive_mkdir wants the directory created *or* already
+  # existing, which means that a 405 (directory already exists) should not be
+  # treated as an error.  other codes may also have similar consideration in
+  # the future.
   elif [[ "${code}" == "$2" ]]; then
     return "${code}"
   else
@@ -221,6 +222,8 @@ dav_upload_folder() {
     exit 1
   fi
 
+  dav_delete "${2}"
+
   find "$1" | while read -r fname; do
     # replace the local path prefix ('../folder1/folder2/folder-to-upload/')
     # with the server path prefix ('private-upload/docs/test/')