now i fixed arrs ckean, maybe?
This commit is contained in:
@@ -93,6 +93,7 @@ ICON_START="▶️" # start command being issued
|
||||
ICON_STARTED="💚" # container confirmed started
|
||||
ICON_RUNNING="🟢" # container already running when checked
|
||||
ICON_SKIP="⏭️" # skipping — already running healthy instance
|
||||
ICON_PROTECTED="🔰" # file/item is protected — never delete
|
||||
ICON_NOT_RUNNING="⭕" # container already stopped when checked
|
||||
|
||||
# Transfer
|
||||
@@ -851,25 +852,25 @@ _release_rsync_on_exit() {
|
||||
# Usage: check_api "http://localhost:8989" "Sonarr" || exit 1
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# translate_path — translate container path to host path using a PATH_MAP array
|
||||
# Used by arr cleanup scripts — arrs store paths using container mounts, not host paths
|
||||
# translate_path — translate container path to host path
|
||||
# Uses ARR_PATH_MAP associative array — must be declared in calling script before use
|
||||
#
|
||||
# Usage:
|
||||
# translate_path "/ext-music/Artist/Album/track.flac" HOST1_LIDARR_PATH_MAP
|
||||
# declare -A ARR_PATH_MAP=(["/ext-music"]="/mnt/user/Music-New")
|
||||
# translate_path "/ext-music/Artist/Album/track.flac"
|
||||
# Returns: /mnt/user/Music-New/Artist/Album/track.flac
|
||||
#
|
||||
# If no match found in PATH_MAP — returns path unchanged
|
||||
# If no match found — returns path unchanged
|
||||
# Handles longest-match first to avoid partial path collisions
|
||||
# ARR_PATH_MAP must be exported or declared global before calling
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
translate_path() {
|
||||
local api_path="$1"
|
||||
local -n _path_map="$2" # nameref to the associative array
|
||||
|
||||
local best_match=""
|
||||
local best_len=0
|
||||
|
||||
# Find longest matching prefix (handles overlapping container paths)
|
||||
for container_path in "${!_path_map[@]}"; do
|
||||
# Find longest matching container path prefix
|
||||
for container_path in "${!ARR_PATH_MAP[@]}"; do
|
||||
if [[ "$api_path" == "$container_path"* ]]; then
|
||||
if [[ "${#container_path}" -gt "$best_len" ]]; then
|
||||
best_match="$container_path"
|
||||
@@ -879,7 +880,7 @@ translate_path() {
|
||||
done
|
||||
|
||||
if [[ -n "$best_match" ]]; then
|
||||
echo "${_path_map[$best_match]}${api_path#$best_match}"
|
||||
echo "${ARR_PATH_MAP[$best_match]}${api_path#$best_match}"
|
||||
else
|
||||
echo "$api_path" # no match — return unchanged
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user