Fixed path mapping persistence and repeated logging issues

- Changed while loop with pipe to readarray with for loop to preserve variable state
- Enhanced path detection to better handle identical structures across mounts
- Added debug logging for path cache hits to trace execution
- Added debug output for processed directories at the end of execution

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-03-04 18:09:04 +01:00
parent bf41b9ad71
commit e64e1115a7
2 changed files with 31 additions and 2 deletions
+12 -1
View File
@@ -120,7 +120,10 @@ main() {
torrent_ids=$(get_torrents)
log_debug "Found $(echo "$torrent_ids" | wc -l) torrents"
echo "$torrent_ids" | while read -r id; do
# Use a regular for loop instead of a pipe to while
# to avoid the subshell issue that causes processed_source_dirs to be lost
readarray -t torrent_ids_array <<< "$torrent_ids"
for id in "${torrent_ids_array[@]}"; do
# Skip empty IDs
if [[ -z "$id" ]]; then
log_debug "Skipping empty torrent ID"
@@ -244,6 +247,14 @@ main() {
fi
done
# Print count of processed directories
if [[ "${DEBUG}" -eq 1 ]]; then
log_debug "Processed source directories count: ${#processed_source_dirs[@]}"
for dir in "${!processed_source_dirs[@]}"; do
log_debug "Processed directory: $dir"
done
fi
# Check disk usage for all directories
for dir in "${REQUIRED_DIRS[@]}"; do
check_disk_usage "${dir}"