Fixed infinite path mapping loop between dsnas1 and dsnas2

- Added path detection to prevent recursive analysis of paths already in destination format
- Added special handling for same logical path on different mounts
- Added early exit in process_copy for identical source and destination paths

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
masterdraco 2025-03-04 18:03:53 +01:00
parent 4f7cb91bc5
commit bf41b9ad71
3 changed files with 27 additions and 0 deletions

View File

@ -191,6 +191,17 @@ main() {
local dst local dst
dst=$(get_destination "${dir}") dst=$(get_destination "${dir}")
# Detect same-path mappings (different mounts)
if [[ "${dir}" != "${dst}" && "${dir}" =~ ^/mnt/dsnas2/ && "${dst}" =~ ^/mnt/dsnas1/ ]]; then
local dir_suffix="${dir#/mnt/dsnas2/}"
local dst_suffix="${dst#/mnt/dsnas1/}"
if [[ "${dir_suffix}" == "${dst_suffix}" ]]; then
log_info "Source and destination are the same logical location with different mounts: ${dir_suffix}"
mark_processed "${hash}"
continue # Skip to next torrent
fi
fi
# Initialize warned_dirs for this directory if needed # Initialize warned_dirs for this directory if needed
if [[ -n "${dir}" ]]; then if [[ -n "${dir}" ]]; then
[[ -z "${warned_dirs["${dir}"]+x}" ]] && warned_dirs["${dir}"]=0 [[ -z "${warned_dirs["${dir}"]+x}" ]] && warned_dirs["${dir}"]=0

View File

@ -215,6 +215,13 @@ process_copy() {
local id="$1" hash="$2" src="$3" dst="$4" local id="$1" hash="$2" src="$3" dst="$4"
local operation_result=0 local operation_result=0
# Check if source and destination are the same or if we've already processed this
if [[ "${src}" == "${dst}" ]]; then
log_info "Source and destination are the same - skipping: ${src}"
mark_processed "${hash}"
return 0
fi
if [[ ! -d "${src}" ]]; then if [[ ! -d "${src}" ]]; then
log_error "Source directory missing: ${src}" log_error "Source directory missing: ${src}"
return 1 return 1

View File

@ -11,11 +11,20 @@ get_destination() {
return "${DEFAULT_DST}" return "${DEFAULT_DST}"
fi fi
# Check if path is already in the cache
if [[ -n "${PATH_CACHE["${source_path}"]+x}" ]]; then if [[ -n "${PATH_CACHE["${source_path}"]+x}" ]]; then
echo "${PATH_CACHE["${source_path}"]}" echo "${PATH_CACHE["${source_path}"]}"
return return
fi fi
# Skip recursive path analysis - only log once
if [[ "${source_path}" =~ ^/mnt/dsnas1/ ]]; then
# Already in destination format, return as is
PATH_CACHE["${source_path}"]="${source_path}"
echo "${source_path}"
return
fi
log_info "Analyzing path: ${source_path}" log_info "Analyzing path: ${source_path}"
local destination="${DEFAULT_DST}" local destination="${DEFAULT_DST}"