Fix transcode session detection for Live TV and Direct Stream

HLS segments are written atomically so lsof never sees them as open.
Cleanup now shows "Active" count (too-young files) which correctly
reflects Live TV / Direct Stream segments. Manager session count now
counts flat file prefixes in addition to subdirs.
This commit is contained in:
Gmer4Lfe
2026-06-14 11:24:21 -04:00
parent a2bcd58f78
commit df18657183
2 changed files with 31 additions and 14 deletions
+16 -7
View File
@@ -501,22 +501,31 @@ for server_entry in "${TRANSCODE_SERVERS[@]}"; do
done
# Storage state
RAM_SESSION_COUNT=$(find "$RAMDISK_PATH/transcoding-temp" \
-mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l)
SSD_SESSION_COUNT=$(find "$TRANSCODE_SSD/transcoding-temp" \
-mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l)
# Sessions may use subdirectories (legacy transcode) or flat files (Live TV / Direct Stream HLS).
# Count both: subdirs per-session, and unique hex session ID prefixes for flat files.
_count_sessions() {
local base="$1/transcoding-temp"
local _dirs _flat
_dirs=$(find "$base" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l)
_flat=$(find "$base" -maxdepth 1 -type f -printf '%f\n' 2>/dev/null | \
grep -oE '^[0-9a-f]{16,}' | sort -u | wc -l)
echo $(( _dirs + _flat ))
}
RAM_SESSION_COUNT=$(_count_sessions "$RAMDISK_PATH")
SSD_SESSION_COUNT=$(_count_sessions "$TRANSCODE_SSD")
unset -f _count_sessions
if [[ "$TOTAL_SESSIONS" -gt 0 ]]; then
echo ""
echo " $ICON_EMBY Total: $TOTAL_SESSIONS | Live TV: $LIVE_TV | Transcoding: $TRANSCODING | Direct: $DIRECT"
if [[ "$RAM_SESSION_COUNT" -gt 0 && "$SSD_SESSION_COUNT" -gt 0 ]]; then
warn "Split state — $RAM_SESSION_COUNT folder(s) ramdisk / $SSD_SESSION_COUNT SSD"
warn "Split state — $RAM_SESSION_COUNT session(s) ramdisk / $SSD_SESSION_COUNT SSD"
warn "Older sessions remain on original location until they end naturally"
elif [[ "$RAM_SESSION_COUNT" -gt 0 ]]; then
log "Storage: ramdisk ($RAM_SESSION_COUNT sessions)"
log "Storage: ramdisk ($RAM_SESSION_COUNT session(s))"
elif [[ "$SSD_SESSION_COUNT" -gt 0 ]]; then
log "Storage: SSD ($SSD_SESSION_COUNT sessions)"
log "Storage: SSD ($SSD_SESSION_COUNT session(s))"
fi
fi