Skip to content

Commit

Permalink
v2.2.7 - Better error detection and messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
tavinus committed Feb 8, 2023
1 parent 35f041d commit 0865822
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions cloudsend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@



CS_VERSION="2.2.6"
CS_VERSION="2.2.7"

TRUE=0
FALSE=1
Expand Down Expand Up @@ -66,6 +66,7 @@ DIRLIST=()
FILELIST=()

CURLEXIT=0
CURLRESPONSES=""



Expand Down Expand Up @@ -120,6 +121,15 @@ curlAddExitCode() {
}


# Curl appended messages
# Will probably be empty if curl was able to perfom as intended
curlAddResponse() {
if isNotEmpty "$1"; then
isEmpty "$CURLRESPONSES" && CURLRESPONSES="$1" || CURLRESPONSES="$CURLRESPONSES"$'\n----------------\n'"$1"
fi
}


# Prints usage information (help)
usage() {
printVersion
Expand Down Expand Up @@ -595,10 +605,14 @@ logResult() {
log $'\n'"SUMMARY"$'\n'"======="$'\n'

if [ $CURLEXIT -eq 0 ]; then
log " > All Curl calls exited without errors"$'\n'" > Attempt to send completed > $fileString"
if isEmpty "$CURLRESPONSES"; then
log " > All Curl calls exited without errors and no WebDAV errors were detected"$'\n'" > Attempt to send completed > $fileString"
else
log " > All Curl calls exited without errors, but webdav errors"$'\n'" were detected while trying to send $fileString"$'\n\n'"Curl Log:"$'\n'"$CURLRESPONSES"
fi
exit 0
fi
log " > Curl errors detected when sending > $fileString"$'\n'" > Summed Curl exit codes: $CURLEXIT"
log " > Curl execution errors were detected when sending > $fileString"$'\n'" > Summed Curl exit codes: $CURLEXIT"
exit $CURLEXIT
}

Expand All @@ -614,9 +628,12 @@ sendFile() {
getScreenSize
eout="$(escapeChars "$OUTFILE")"
# Send file
#echo "$CURLBIN"$INSECURE$VERBOSE -T "$1" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX$INNERPATH/$eout"
"$CURLBIN"$LIMITCMD$INSECURE$VERBOSE$GLOBCMD -T "$1" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX$INNERPATH/$eout" | cat ; test ${PIPESTATUS[0]} -eq 0
curlAddExitCode $?
#echo "$CURLBIN"$INSECURE$VERBOSE -T \""$1"\" -u \""$FOLDERTOKEN":"$PASSWORD"\" -H \""$HEADER"\" \""$CLOUDURL/$PUBSUFFIX$INNERPATH/$eout"\"
#"$CURLBIN"$LIMITCMD$INSECURE$VERBOSE$GLOBCMD -T "$1" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX$INNERPATH/$eout" | cat ; test ${PIPESTATUS[0]} -eq 0
resp="$("$CURLBIN"$LIMITCMD$INSECURE$VERBOSE$GLOBCMD -T "$1" -u "$FOLDERTOKEN":"$PASSWORD" -H "$HEADER" "$CLOUDURL/$PUBSUFFIX$INNERPATH/$eout")"
stat=$?
curlAddResponse "$resp"
curlAddExitCode $stat
}


Expand Down

0 comments on commit 0865822

Please sign in to comment.