fix(downloads): R5 S1 — downloads robustness
- pick the produced file safely: Path("") is Path("."), which passes .exists(),
so a missing yt-dlp filepath skipped the staging fallback and crashed in
with_name ("PosixPath('.') has an empty name") on non-YouTube sources
- unwrap a playlist/multi_video extraction to the entry that carries the media
- run_ffmpeg: drain stderr while it runs (a full 64KB pipe blocked ffmpeg
forever and hung the worker thread), 1s cancel polling, stall watchdog and a
bounded wait on exit
- escape apostrophes/backslashes in the ffmpeg concat list (pre-0.51.0 names)
- sweep orphaned HLS segment dirs at startup (nothing else ever reaped them)
This commit is contained in:
@@ -27,6 +27,7 @@ from starlette.middleware.sessions import SessionMiddleware
|
||||
from app import auth, state
|
||||
from app.config import settings
|
||||
from app.db import SessionLocal
|
||||
from app.plex import stream as plex_stream
|
||||
from app.routes import (
|
||||
admin,
|
||||
audit as audit_routes,
|
||||
@@ -67,6 +68,11 @@ async def lifespan(app: FastAPI):
|
||||
" Open the install wizard (internal access only):\n %s",
|
||||
url,
|
||||
)
|
||||
# No HLS session survives a restart (they live in this process), so anything still on disk is
|
||||
# a crashed run's segments — sweep them or they accumulate forever.
|
||||
swept = plex_stream.sweep_orphans()
|
||||
if swept:
|
||||
log.info("swept %d orphaned HLS segment directories", swept)
|
||||
start_scheduler()
|
||||
try:
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user