From 7cdec916a0d234fa11b3bfb16a8715837e4a26a6 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Fri, 24 Jul 2020 22:09:27 +0530 Subject: [PATCH] Fix uploading for files with spaces and other chars my bad, missed in refactoring --- bash/drive-utils.bash | 8 ++++++-- sh/drive-utils.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bash/drive-utils.bash b/bash/drive-utils.bash index 6b0f740..2405bbf 100755 --- a/bash/drive-utils.bash +++ b/bash/drive-utils.bash @@ -339,8 +339,12 @@ _upload_file_main() { retry="${RETRY:-0}" && unset RETURN_STATUS until [[ ${retry} -le 0 ]] && [[ -n ${RETURN_STATUS} ]]; do - { eval _upload_file "${UPLOAD_MODE:-create}" "${file:-${2}}" "${dirid:-${3}}" "${ACCESS_TOKEN}" "${4:+2> /dev/null 1>&2}" && RETURN_STATUS=1 && break; } || - { RETURN_STATUS=2 retry="$((retry - 1))" && continue; } + if [[ -n ${4} ]]; then + _upload_file "${UPLOAD_MODE:-create}" "${file:-${2}}" "${dirid:-${3}}" "${ACCESS_TOKEN}" 2> /dev/null 1>&2 && RETURN_STATUS=1 && break + else + _upload_file "${UPLOAD_MODE:-create}" "${file:-${2}}" "${dirid:-${3}}" "${ACCESS_TOKEN}" && RETURN_STATUS=1 && break + fi + RETURN_STATUS=2 retry="$((retry - 1))" && continue done printf "%b" "${4:+${RETURN_STATUS}\n}" 1>&"${RETURN_STATUS}" return 0 diff --git a/sh/drive-utils.sh b/sh/drive-utils.sh index e3a2453..2453a51 100755 --- a/sh/drive-utils.sh +++ b/sh/drive-utils.sh @@ -342,8 +342,12 @@ _upload_file_main() { retry_upload_file_main="${RETRY:-0}" && unset RETURN_STATUS until [ "${retry_upload_file_main}" -le 0 ] && [ -n "${RETURN_STATUS}" ]; do - { eval _upload_file "${UPLOAD_MODE:-create}" "${file_upload_file_main:-${2}}" "${dirid_upload_file_main:-${3}}" "${ACCESS_TOKEN}" "${4:+2> /dev/null 1>&2}" && RETURN_STATUS=1 && break; } || - { RETURN_STATUS=2 retry_upload_file_main="$((retry_upload_file_main - 1))" && continue; } + if [ -n "${4}" ]; then + _upload_file "${UPLOAD_MODE:-create}" "${file_upload_file_main:-${2}}" "${dirid_upload_file_main:-${3}}" "${ACCESS_TOKEN}" 2> /dev/null 1>&2 && RETURN_STATUS=1 && break + else + _upload_file "${UPLOAD_MODE:-create}" "${file_upload_file_main:-${2}}" "${dirid_upload_file_main:-${3}}" "${ACCESS_TOKEN}" && RETURN_STATUS=1 && break + fi + RETURN_STATUS=2 retry_upload_file_main="$((retry_upload_file_main - 1))" && continue done printf "%b" "${4:+${RETURN_STATUS}\n}" 1>&"${RETURN_STATUS}" return 0