Actually adds and removes from the queue and works. Accidentally submitted a broken version.

This commit is contained in:
Tony Blyler 2015-02-09 12:20:00 -05:00
parent e347363249
commit cd5263cb5e

View file

@ -341,7 +341,7 @@ while true; do
fi fi
# start the download and record the PID # start the download and record the PID
rsync -hrvP --inplace "${SSH_USER}@${SSH_SERVER}:${SSH_SERVER_DOWNLOAD_PATH}/${torrent_name}" "${TORRENT_TMP_DOWNLOAD}/" & rsync -hrvP --inplace "${SSH_USER}@${SSH_SERVER}:${SSH_SERVER_DOWNLOAD_PATH}/${torrent_name}" "${TORRENT_TMP_DOWNLOAD}/" > /dev/null &
RUNNING_RSYNCS[${torrent_hash}]=$! RUNNING_RSYNCS[${torrent_hash}]=$!
fi fi
done done
@ -351,7 +351,7 @@ while true; do
for torrent_hash in "${!RUNNING_RSYNCS[@]}"; do for torrent_hash in "${!RUNNING_RSYNCS[@]}"; do
pid=${RUNNING_RSYNCS[$torrent_hash]} pid=${RUNNING_RSYNCS[$torrent_hash]}
# check to see if the given PID is still running # check to see if the given PID is still running
if [[ `jobs | grep -c $pid` -eq 0 ]]; then if ! kill -0 "${pid}" 2> /dev/null; then
# get the return code of the PID # get the return code of the PID
wait $pid wait $pid
return=$? return=$?
@ -361,7 +361,7 @@ while true; do
if [[ $? ]]; then if [[ $? ]]; then
final_location_dir="${TORRENT_DOWNLOAD}" final_location_dir="${TORRENT_DOWNLOAD}"
if [[ `dirname "${TORRENT_QUEUE[$torrent_hash]}"` != "${TORRENT_FILE_PATH}" ]]; then if [[ `dirname "${TORRENT_QUEUE[$torrent_hash]}"` != "${TORRENT_FILE_PATH}" ]]; then
final_location_dir="${final_location_dir}/$(basename `dirname "${TORRENT_FILE_PATH}"`)" final_location_dir="${final_location_dir}/$(basename "`dirname "${TORRENT_QUEUE[$torrent_hash]}"`")"
fi fi
if [[ ! -d "${final_location_dir}" ]]; then if [[ ! -d "${final_location_dir}" ]]; then
@ -369,6 +369,7 @@ while true; do
fi fi
mv "${TORRENT_TMP_DOWNLOAD}/${torrent_name}" "${final_location_dir}/" mv "${TORRENT_TMP_DOWNLOAD}/${torrent_name}" "${final_location_dir}/"
rm "${TORRENT_QUEUE[$torrent_hash]}"
unset TORRENT_QUEUE[$torrent_hash] unset TORRENT_QUEUE[$torrent_hash]
else else
echo "Failed to get torrent name for ${TORRENT_QUEUE[$torrent_hash]}" echo "Failed to get torrent name for ${TORRENT_QUEUE[$torrent_hash]}"