Skip to content

Commit 8cc1d26

Browse files
noobyysaurajhakimifr
authored andcommitted
ksau: implement error handler for progressbar
Co-authored-by: Hakimi0804 <[email protected]> Co-authered-by: noobyysauraj <[email protected]>
1 parent 135e380 commit 8cc1d26

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ksau

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ Purple='\033[0;35m' # Purple
1515
Cyan='\033[0;36m' # Cyan
1616
White='\033[0;37m' # White
1717

18-
18+
set -o pipefail
1919
readonly file="$2"
2020
readonly u_folder="$3"
21+
readonly status_dir="$(mktemp -d)"
22+
23+
trap "rm -rf $status_dir" EXIT
2124

2225
dependencies () {
2326
echo ""
@@ -108,9 +111,9 @@ rclone_progress_bar() {
108111
echo "Starting download..."
109112
rm -f log
110113
touch log
111-
rclone -P --checkers=32 --onedrive-chunk-size 60M copy "$file" oned:/"${u_folder}" | tee log >/dev/null || DL_FAILED=true &
114+
rclone -P --checkers=32 --onedrive-chunk-size 60M copy "$file" oned:/"${u_folder}" | tee log >/dev/null || touch "$status_dir/failed" &
112115
until [ -z "$(jobs -r)" ]; do
113-
if [ -n "$DL_FAILED" ]; then
116+
if [ -f "$status_dir/failed" ]; then
114117
echo
115118
echo "${Red}Upload failed!${Normal}"
116119
break
@@ -195,7 +198,7 @@ upload () {
195198
echo "Initializing process, might take up to 10 seconds..."
196199
rclone_progress_bar
197200
wait
198-
if [ -n "$DL_FAILED" ]; then
201+
if [ -f "$status_dir/failed" ]; then
199202
echo -e "\rUpload Failed .......\n"
200203
exit 1
201204
fi

0 commit comments

Comments
 (0)