After a rescan: one renumbered programme rechecks the channel's whole schedule in one go (1.0 RC3-8, build 50)
release-gate / verify (push) Successful in 8m26s
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m16s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m44s

15 November 2026: the scan the night before gave some booked programmes new numbers; Orbit found each again as it came
up, but only after asking for the old one first (35 failed asks overnight, Detour re-filed four times). Now the first
re-file on a channel checks the rest of its schedule against the server, fifty IDs a request, and re-files every one
that's gone, keeping its slot; at most once an hour a channel, in the background. Tuning ahead no longer asks again for
a programme the server has said it doesn't have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 08:29:11 +00:00
co-authored by Claude Opus 5.5
parent 805f75f9c0
commit f2beb6ed76
5 changed files with 92 additions and 2 deletions
@@ -108,3 +108,41 @@ class LighterCopyTest {
assertEquals(1, searches)
}
}
/** 15 November 2026: one renumbered programme means a rescan; the rest of the channel's schedule is checked in one go. */
class RecheckAfterRescanTest {
@org.junit.Before fun server() { EmbyServer.origin = "https://emby.example.com" }
@org.junit.After fun noServer() { EmbyServer.origin = "" }
private val min = 60_000L
private fun ep(id: String, n: Int, start: Long) = ScheduleEntry("show", EpisodeMark(1, n),
ScheduledMedia(SampleItem("Fixture Show / S1 E$n / Part $n", "Episode", 22, "", id, 22 * min), "src$id", 22 * min), start)
private fun row(id: String, n: Int) = JSONObject().put("Id", id).put("Type", "Episode").put("Name", "Part $n").put("ParentIndexNumber", 1).put("IndexNumber", n)
.put("MediaSources", JSONArray().put(JSONObject().put("Id", "src$id").put("Container", "mkv").put("RunTimeTicks", 22 * min * 10_000)))
@Test fun theGoneOnesAreFoundAgainAndTheRestLeftAlone() {
val dir = kotlin.io.path.createTempDirectory("recheck").toFile()
try {
val asked = mutableListOf<String>()
val transport = EmbyTransport { r ->
asked += r.path
when {
"&Ids=" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(JSONObject().put("Id", "old1aaaa"))).toString())
"IncludeItemTypes=Series" in r.path -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(JSONObject().put("Id", "show2").put("Name", "Fixture Show"))).toString())
r.path.startsWith("/Shows/show2/Episodes") -> EmbyReply(200, JSONObject().put("Items", JSONArray().put(row("new2bbbb", 2)).put(row("new3cccc", 3))).toString())
else -> EmbyReply(404, "")
}
}
val session = EmbySampleSession(transport, "fixture-token-private", "u1", EmbySample(listOf(SampleItem("Fixture", "Movie", 90, "mkv", "one")), 1))
val store = ScheduleStore(dir)
val p = ChannelPlan(listOf(ep("old0zzzz", 1, 0), ep("old1aaaa", 1, 22 * min), ep("old2bbbb", 2, 44 * min), ep("old3cccc", 3, 66 * min)), ScheduleCursor())
store.savePlan("u1", 601, p)
val channel = ScheduledChannel(SampleChannel(listOf(p.entries[0].media, p.entries[1].media), "Vortex", 601), p)
assertEquals(2, PlanEdits.recheck(session, channel, store, 0))
assertEquals(listOf("old0zzzz", "old1aaaa", "new2bbbb", "new3cccc"), store.loadPlan("u1", 601)!!.entries.map { it.media.item.id })
// Slots kept; the programme already on (at 0) isn't part of the check; one request checked all three ahead.
assertEquals(listOf(0L, 22 * min, 44 * min, 66 * min), channel.plan.entries.map { it.startMs })
assertEquals(1, asked.count { "&Ids=" in it })
assertFalse(asked.first { "&Ids=" in it }.contains("old0zzzz"))
} finally { dir.deleteRecursively() }
}
}