Make all arr library-list fetches cache-first with live fallback
Every script that fetches the full Lidarr/Sonarr/Radarr tracked-library list now goes through arr_get_tracked_data() instead of hitting the API directly -- cache-first when fresh, live fetch as fallback when stale, waits out an active rescan before either. Per-item file data (trackFile/ episodefile/moviefile) stays live-only everywhere, since that's the actual disk-truth these scripts' decisions depend on and was never part of what's cached. Also adds arr_cache_prefill.sh to CRITICAL_MAINTENANCE_SCRIPTS (30min tier) with a short 1min wait ceiling, so the cache stays consistently fresh instead of only refreshing whenever some other script happens to write through. A full cache refresh for all three arrs measured at ~12s total live -- nothing like the multi-hour cost of an actual rescan.
This commit is contained in:
+14
-3
@@ -659,9 +659,20 @@ REMOTE
|
||||
|
||||
_local_library() {
|
||||
local url="$1" api_key="$2" api_ver="$3" endpoint="$4"
|
||||
curl -sf --max-time "$ARR_SYNC_API_TIMEOUT" \
|
||||
-H "X-Api-Key: $api_key" \
|
||||
"${url}/api/${api_ver}/${endpoint}" 2>/dev/null
|
||||
# endpoint doubles as arr_type here — artist/series/movie match lidarr/sonarr/radarr's
|
||||
# ARR_LIBRARY_ENDPOINT values exactly, so the same lookup works either direction.
|
||||
local arr_type
|
||||
case "$endpoint" in
|
||||
artist) arr_type="lidarr" ;;
|
||||
series) arr_type="sonarr" ;;
|
||||
movie) arr_type="radarr" ;;
|
||||
esac
|
||||
# Cache-first — arr_get_tracked_data() serves the shared cache when it's fresh (kept
|
||||
# current every 30min by arr_cache_prefill.sh in CRITICAL_MAINTENANCE_SCRIPTS), falls back
|
||||
# to a live fetch when it's stale, and waits out an active rescan before either. This is
|
||||
# the LOCAL host's library only — the remote side of this sync isn't cached, since the
|
||||
# shared cache is per-host by design.
|
||||
arr_get_tracked_data "$arr_type" "$url" "$api_key" "$api_ver"
|
||||
}
|
||||
|
||||
_local_defaults() {
|
||||
|
||||
Reference in New Issue
Block a user