Added enhanced diagnostics for torrent list retrieval

- Added verbose logging to identify when no torrents are found
- Added raw transmission command output logging to troubleshoot connection issues
- Improved tracking of torrent ID extraction from command output
- Made torrent count always visible, not just in debug mode

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-03-04 18:12:11 +01:00
parent e64e1115a7
commit 1119f38fd6
2 changed files with 30 additions and 5 deletions
@@ -113,15 +113,33 @@ process_removal() {
# get_torrents: Retrieves a list of torrents from Transmission
get_torrents() {
local cmd="transmission-remote ${TRANSMISSION_IP}:${TRANSMISSION_PORT} -n ${TRANSMISSION_USER}:${TRANSMISSION_PASSWORD} -l"
log_debug "Running command: $cmd"
# Log the full command we're about to run, sensitive info redacted for logging
local cmd_display="transmission-remote ${TRANSMISSION_IP}:${TRANSMISSION_PORT} -n [redacted] -l"
log_info "Running command: $cmd_display"
# Execute the actual command
local real_cmd="transmission-remote ${TRANSMISSION_IP}:${TRANSMISSION_PORT} -n ${TRANSMISSION_USER}:${TRANSMISSION_PASSWORD} -l"
local output
output=$(retry_command "$cmd" 3 20)
output=$(retry_command "$real_cmd" 3 20)
# Log the raw output for debugging
log_info "Raw command output:"
log_info "$output"
# Extract IDs directly using awk
# Skip the header line (NR>1) and print the first column
# The IDs are right-aligned with spaces in front, so we need to trim them
echo "$output" | awk 'NR>1 && NF>1 {gsub(/^[ ]+/, "", $1); if ($1 ~ /^[0-9]+$/) print $1}'
local torrent_ids
torrent_ids=$(echo "$output" | awk 'NR>1 && NF>1 {gsub(/^[ ]+/, "", $1); if ($1 ~ /^[0-9]+$/) print $1}')
# Check if we found any torrents
if [[ -z "$torrent_ids" ]]; then
log_info "No torrent IDs found in transmission output"
else
log_info "Found torrent IDs: $torrent_ids"
fi
echo "$torrent_ids"
}
# get_torrent_info: Gets detailed info for a specific torrent