forked from maple3142/aria2c-ariang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
on-complete.sh
29 lines (23 loc) · 1010 Bytes
/
on-complete.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
filePath=$3
relativePath=${filepath#./downloads/}
topPath=./downloads/${relativePath%%/*} # It will be the path of folder when it has multiple files, otherwise it will be the same as file path.
LIGHT_GREEN_FONT_PREFIX="\033[1;32m"
FONT_COLOR_SUFFIX="\033[0m"
INFO="[${LIGHT_GREEN_FONT_PREFIX}INFO${FONT_COLOR_SUFFIX}]"
echo -e "$(date +"%m/%d %H:%M:%S") ${INFO} Delete .aria2 file ..."
if [ $2 -eq 0 ]; then
exit 0
elif [ -e "${filepath}.aria2" ]; then
rm -vf "${filepath}.aria2"
elif [ -e "${topPath}.aria2" ]; then
rm -vf "${topPath}.aria2"
fi
echo -e "$(date +"%m/%d %H:%M:%S") ${INFO} Delete .aria2 file finish"
echo "$(($(cat numUpload)+1))" > numUpload # Plus 1
if [[ $2 -eq 1 ]]; then # single file
rclone -v --config="rclone.conf" copy "$3" "DRIVE:$RCLONE_DESTINATION" 2>&1
elif [[ $2 -gt 1 ]]; then # multiple file
rclone -v --config="rclone.conf" copy "$topPath" "DRIVE:$RCLONE_DESTINATION/${relativePath%%/*}"
fi
echo "$(($(cat numUpload)-1))" > numUpload # Minus 1