feat(subscriptions): newly added enabled sources start in backfill mode
A freshly created subscription has no gallery-dl archive yet, so the first poll in tick mode would walk forever — exit:20 doesn't trip until 20 contiguous archive-hits, and there are none. The wall-clock cap kicks in mid-walk, and the partial-success classifier (plan #544) gracefully labels it status=ok, but the operator still wonders why their new subscription isn't grabbing the back-catalog. Pre-arm `backfill_runs_remaining = 3` on create() when `enabled=True`. Same default as the manual "Deep scan" button, same auto-decrement and auto-reset rules — once the queue drains (clean exit + zero new files) or the budget runs out, tick mode resumes naturally. Disabled sources (sidecar synthetics with `url='sidecar:<platform>:<slug>'` that arrive disabled = False, or operator-added sources that start disabled deliberately) skip the pre-arm — they're never polled, no budget to waste.
This commit is contained in:
@@ -213,3 +213,31 @@ async def test_set_backfill_runs_raises_when_source_missing(db):
|
||||
svc = SourceService(db)
|
||||
with pytest.raises(LookupError):
|
||||
await svc.set_backfill_runs(99999, 3)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_new_enabled_source_starts_in_backfill_mode(db):
|
||||
"""Plan #544 follow-up: freshly added enabled sources have no archive
|
||||
yet, so the first few polls would blow the wall-clock cap in tick
|
||||
mode. Pre-arm backfill so the initial walks use the longer timeout."""
|
||||
artist = await _artist(db, "Alice")
|
||||
svc = SourceService(db)
|
||||
rec = await svc.create(
|
||||
artist_id=artist.id, platform="patreon",
|
||||
url="https://patreon.com/alice-new",
|
||||
)
|
||||
assert rec.backfill_runs_remaining == 3
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_new_disabled_source_skips_backfill(db):
|
||||
"""Disabled sources (incl. sidecar synthetics that arrive disabled) are
|
||||
never polled, so don't burn a backfill budget on them."""
|
||||
artist = await _artist(db, "Alice")
|
||||
svc = SourceService(db)
|
||||
rec = await svc.create(
|
||||
artist_id=artist.id, platform="patreon",
|
||||
url="https://patreon.com/alice-disabled",
|
||||
enabled=False,
|
||||
)
|
||||
assert rec.backfill_runs_remaining == 0
|
||||
|
||||
Reference in New Issue
Block a user