forked from P3TERX/aria2.conf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.sh
38 lines (34 loc) · 1.12 KB
/
delete.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
30
31
32
33
34
35
36
37
38
#!/bin/bash
#=====================================================
# https://github.com/P3TERX/aria2.conf
# File name:delete.sh
# Description: Delete files after Aria2 download error
# Lisence: MIT
# Version: 1.9
# Author: P3TERX
# Blog: https://p3terx.com
#=====================================================
# Aria2下载目录
# TIPS:一键脚本推荐使用选项进行修改,Docker 无需修改。
downloadpath='/root/Download'
#=====================================================
filepath=$3
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}
if [ $2 -eq 0 ]
then
exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
[ -e "$filepath".aria2 ] && rm -vf "$filepath".aria2 "$filepath"
exit 0
elif [ "$path" != "$filepath" ] && [ $2 -gt 1 ]
then
[ -e "$path".aria2 ] && rm -vrf "$path".aria2 "$path"
exit 0
elif [ "$path" != "$filepath" ] && [ $2 -eq 1 ]
then
[ -e "$filepath".aria2 ] && rm -vf "$filepath".aria2 "$filepath"
find "${downloadpath}" ! -path "${downloadpath}" -depth -type d -empty -exec rm -vrf {} \;
exit 0
fi