fix: allow genuinely new playlist ingest without fresh Player evidence
The evidence gate on enqueue_download blocked every download, including a URL that could only land in a slot store.reserve_download already proves is empty and unguarded. After a Controller-only restart with the Player still connected and idle, no fresh detailed status ever arrives, so this could deadlock all new ingest indefinitely even though nothing unsafe would occur. Narrow the gate to only require fresh evidence when the URL already occupies a non-empty slot (refresh/reuse). Deletion, expiry, and cleanup/recovery gating are unchanged.
This commit is contained in:
@@ -962,6 +962,31 @@ class ControllerStore:
|
||||
(slot,),
|
||||
).fetchone() is not None
|
||||
|
||||
def find_occupied_slot_for_url(self, url: str) -> int | None:
|
||||
"""Return the slot already holding ``url``, if any.
|
||||
|
||||
A non-``None`` result means ingest for this exact URL would reuse or
|
||||
refresh a slot that already holds media, rather than land in a slot
|
||||
that is genuinely empty. Callers use this to decide whether an
|
||||
ingest request needs fresh Player evidence before proceeding.
|
||||
"""
|
||||
|
||||
if not isinstance(url, str):
|
||||
return None
|
||||
url = url.strip()
|
||||
if not url:
|
||||
return None
|
||||
with self._lock:
|
||||
row = self.connection.execute(
|
||||
"""
|
||||
SELECT slot_number FROM slots
|
||||
WHERE url = ? AND media_state <> 'empty'
|
||||
ORDER BY slot_number LIMIT 1
|
||||
""",
|
||||
(url,),
|
||||
).fetchone()
|
||||
return None if row is None else int(row["slot_number"])
|
||||
|
||||
def mark_download_running(self, job_id: str, slot: int, generation: int) -> bool:
|
||||
with self._transaction() as connection:
|
||||
now = self._now()
|
||||
|
||||
Reference in New Issue
Block a user