Handle torrent files with spaces in their name
This commit is contained in:
parent
cd5263cb5e
commit
30b0258294
1 changed files with 32 additions and 30 deletions
22
hoarder.sh
22
hoarder.sh
|
@ -253,16 +253,15 @@ while true; do
|
|||
echo "${TORRENT_FILE_PATH} Does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OIFS="$IFS"
|
||||
IFS=$'\n'
|
||||
# enumerate the .torrent file directory
|
||||
for file in `ls "${TORRENT_FILE_PATH}"`; do
|
||||
# store the file/directory's full path
|
||||
file="${TORRENT_FILE_PATH}/${file}"
|
||||
for file in `find "${TORRENT_FILE_PATH}"`; do
|
||||
# check if the path is a directory
|
||||
if [[ -d "${file}" ]]; then
|
||||
# enumerate the directory
|
||||
for sub_file in `ls "${file}"`; do
|
||||
# store the file/directory's full path
|
||||
sub_file="${file}/${sub_file}"
|
||||
for sub_file in `find "${file}" -type f`; do
|
||||
# this is the furthest we will descend
|
||||
if [[ -f "${sub_file}" ]]; then
|
||||
# get the torrent hash for the .torrent file
|
||||
|
@ -293,6 +292,7 @@ while true; do
|
|||
fi
|
||||
fi
|
||||
done
|
||||
IFS="$OIFS"
|
||||
|
||||
# go through the torrent queue
|
||||
for torrent_hash in "${!TORRENT_QUEUE[@]}"; do
|
||||
|
@ -317,9 +317,12 @@ while true; do
|
|||
fi
|
||||
done
|
||||
|
||||
# if the amount of running rsyncs is belwo the desire amount, run items from the queue
|
||||
if [[ ${#RUNNING_RSYNCS[@]} -lt ${RSYNC_PROCESSES} ]]; then
|
||||
# if the amount of running rsyncs is below the desire amount, run items from the queue
|
||||
for torrent_hash in "${!TORRENT_QUEUE[@]}"; do
|
||||
# break out of the loop if we added enough jobs already
|
||||
if [[ ${#RUNNING_RSYNCS[@]} -ge ${RSYNC_PROCESSES} ]]; then
|
||||
break
|
||||
fi
|
||||
# make sure this torrent is not already being downloaded
|
||||
if [[ ${RUNNING_RSYNCS[${torrent_hash}]+_} ]]; then
|
||||
continue
|
||||
|
@ -341,11 +344,10 @@ while true; do
|
|||
fi
|
||||
|
||||
# start the download and record the PID
|
||||
rsync -hrvP --inplace "${SSH_USER}@${SSH_SERVER}:${SSH_SERVER_DOWNLOAD_PATH}/${torrent_name}" "${TORRENT_TMP_DOWNLOAD}/" > /dev/null &
|
||||
rsync -hrvP --inplace "${SSH_USER}@${SSH_SERVER}:\"${SSH_SERVER_DOWNLOAD_PATH}/${torrent_name}"\" "${TORRENT_TMP_DOWNLOAD}/" > /dev/null &
|
||||
RUNNING_RSYNCS[${torrent_hash}]=$!
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# checkup on the running rsyncs
|
||||
for torrent_hash in "${!RUNNING_RSYNCS[@]}"; do
|
||||
|
|
Loading…
Reference in a new issue