From bb709b27625d6a6c189a0b44cb2fa524ab4fce96 Mon Sep 17 00:00:00 2001 From: FailedProxy Date: Sun, 19 Apr 2026 12:36:44 -0400 Subject: [PATCH] fixed in the way transcode is set up, all scripts in that folder adjusted --- Transcodes/ramdisk_setup.sh | 32 ++++++++++++++++++++++++++++++++ Transcodes/transcode_cleanup.sh | 7 +++++-- Transcodes/transcode_manager.sh | 17 +++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Transcodes/ramdisk_setup.sh b/Transcodes/ramdisk_setup.sh index 61d1608..6f2c15e 100644 --- a/Transcodes/ramdisk_setup.sh +++ b/Transcodes/ramdisk_setup.sh @@ -176,6 +176,38 @@ else fi fi +# ----------------------------------------------------------------------------------------------- +# ━━━ $ICON_GEAR Transcoding-temp Directory ━━━ +# Creates the transcoding-temp folder on the ramdisk proactively. +# If this folder doesn't exist on the ramdisk Emby creates it wherever it finds +# a writable path first — which may be the SSD fallback — locking all sessions +# onto SSD even when the symlink points at the ramdisk. +# Creating it here guarantees Emby always finds it on the ramdisk at session start. +# ----------------------------------------------------------------------------------------------- +echo "" +echo "━━━ $ICON_GEAR Transcoding Temp Directory ━━━" + +TRANSCODE_TEMP_DIR="${RAMDISK_PATH}/transcoding-temp" + +if [[ "$DRY_RUN" == true ]]; then + warn "DRY RUN — would create $TRANSCODE_TEMP_DIR" +else + if [[ -d "$TRANSCODE_TEMP_DIR" ]]; then + info "transcoding-temp already exists on ramdisk" + else + mkdir -p "$TRANSCODE_TEMP_DIR" && \ + success "Created transcoding-temp on ramdisk: $TRANSCODE_TEMP_DIR" || \ + { error "Failed to create transcoding-temp on ramdisk"; SETUP_SUCCESS=false; } + fi + + # Apply correct permissions so Emby (abc/nobody:users) can write to it + if [[ -d "$TRANSCODE_TEMP_DIR" ]]; then + chmod "$TRANSCODE_CHMOD" "$TRANSCODE_TEMP_DIR" + chown "$TRANSCODE_OWNER" "$TRANSCODE_TEMP_DIR" + success "Permissions set on transcoding-temp" + fi +fi + # ----------------------------------------------------------------------------------------------- # ━━━ $ICON_GEAR Permissions ━━━ # ----------------------------------------------------------------------------------------------- diff --git a/Transcodes/transcode_cleanup.sh b/Transcodes/transcode_cleanup.sh index cbd95de..07fa456 100644 --- a/Transcodes/transcode_cleanup.sh +++ b/Transcodes/transcode_cleanup.sh @@ -131,9 +131,12 @@ cleanup_location() { done < <(find "$location" -type f -mmin +"$max_age" 2>/dev/null) - # Remove empty directories left behind + # Remove empty directories left behind — but NEVER remove transcoding-temp itself + # transcoding-temp must always exist on the ramdisk so Emby finds it there first + # If deleted Emby falls back to the SSD version and all new sessions land on SSD if [[ "$DRY_RUN" == false ]]; then - find "$location" -mindepth 1 -type d -empty -delete 2>/dev/null + find "$location" -mindepth 1 -type d -empty \ + ! -name "transcoding-temp" -delete 2>/dev/null fi # Format bytes freed for display diff --git a/Transcodes/transcode_manager.sh b/Transcodes/transcode_manager.sh index 02a91d4..47b1c71 100644 --- a/Transcodes/transcode_manager.sh +++ b/Transcodes/transcode_manager.sh @@ -252,6 +252,23 @@ else RAMDISK_SIZE_ACTUAL=$(df "$RAMDISK_PATH" --output=size -h | tail -1 | tr -d ' ') success "$ICON_RAM Ramdisk mounted — size: $RAMDISK_SIZE_ACTUAL" fix_permissions "$RAMDISK_PATH" + + # Guarantee transcoding-temp exists on ramdisk + # If missing Emby creates it wherever it finds a writable path first — + # which may be the SSD fallback — locking all new sessions onto SSD + # even when the symlink correctly points at the ramdisk. + TRANSCODE_TEMP_RAM="${RAMDISK_PATH}/transcoding-temp" + TRANSCODE_TEMP_SSD="${TRANSCODE_SSD}/transcoding-temp" + + if [[ ! -d "$TRANSCODE_TEMP_RAM" ]]; then + warn "transcoding-temp missing from ramdisk — creating now" + mkdir -p "$TRANSCODE_TEMP_RAM" + chmod "$TRANSCODE_CHMOD" "$TRANSCODE_TEMP_RAM" + chown "$TRANSCODE_OWNER" "$TRANSCODE_TEMP_RAM" + success "transcoding-temp created on ramdisk — new sessions will use ramdisk" + else + log "transcoding-temp exists on ramdisk — ok" + fi fi # -----------------------------------------------------------------------------------------------