By default, aria2 does not move completed downloads to a different directory than the one where downloads started. However, this behavior can be customized through the aria2 event hooks.
I used the on-download-complete
event. A bash script can be specified in /home/she/.aria2/aria2.conf
for this event as on line 15:
-
dir=/home/she/aria2/download
-
input-file=/home/she/.aria2/session
-
log=/home/she/.aria2/log
-
dht-listen-port=36801
-
listen-port=36801
-
max-overall-upload-limit=512K
-
max-upload-limit=0
-
seed-ratio=1.0
-
seed-time=60
-
enable-rpc=true
-
rpc-listen-all=false
-
rpc-listen-port=6800
-
rpc-secret=1234567890
-
log-level=notice
-
on-download-complete=/home/she/.aria2/mvcompleted.sh
-
max-overall-download-limit=0
-
max-download-limit=0
-
save-session=/home/she/.aria2/session
The bash script /home/she/.aria2/mvcompleted.sh
reads:
-
#!/bin/sh
-
-
# $1 is gid.
-
# $2 is the number of files.
-
# $3 is the path of the first file.
-
-
DOWNLOAD=/home/she/aria2/download # no trailing slash!
-
COMPLETE=/home/she/aria2/complete # no trailing slash!
-
LOG=/home/she/.aria2/mvcompleted.log
-
SRC=$3
-
-
if [ "$2" == "0" ]; then
-
echo `date` "INFO no file to move for" "$1". >> "$LOG"
-
exit 0
-
fi
-
-
while true; do
-
DIR=`dirname "$SRC"`
-
if [ "$DIR" == "$DOWNLOAD" ]; then
-
echo `date` "INFO " "$3" moved as "$SRC". >> "$LOG"
-
mv --backup=t "$SRC" "$COMPLETE" >> "$LOG" 2>&1
-
exit $?
-
elif [ "$DIR" == "/" -o "$DIR" == "." ]; then
-
echo `date` ERROR "$3" not under "$DOWNLOAD". >> "$LOG"
-
exit 1
-
else
-
SRC=$DIR
-
fi
-
done
Note that on-download-complete
is triggered for all types of downloads when completed, while there is also a on-bt-download-complete
, which is triggered after downloading is completed but before seeding is completed for BitTorrent downloads.
Post new comment