fix(quota): don't let the demo account persist deep_requested (S1, finding 2)
The demo account is shared, so writing deep_requested onto its subscription polluted shared state (harmless today — the scheduler's deep paths are human-only — but a future scheduler path trusting the flag would leak quota). Guard the flag WRITE at the source (not user.is_demo), which also makes deep_turned_on always False for demo, so the redundant is_demo check on the immediate backfill is removed.
This commit is contained in:
@@ -391,7 +391,10 @@ def update_channel(
|
||||
sub.priority = int(payload["priority"])
|
||||
if "hidden" in payload:
|
||||
sub.hidden = bool(payload["hidden"])
|
||||
if "deep_requested" in payload:
|
||||
# The demo account is SHARED, so it must not persist deep_requested (a quota-relevant flag) onto
|
||||
# the shared subscription — skip the write entirely for demo, which also keeps deep_turned_on
|
||||
# False so the immediate backfill below can never fire for it.
|
||||
if "deep_requested" in payload and not user.is_demo:
|
||||
# Opt this channel into (or out of) full-history backfill. The deep scheduler
|
||||
# picks the flag up on its next run; turning it off won't undo already-fetched
|
||||
# videos, it just stops further deep paging if nobody else still wants it.
|
||||
@@ -403,14 +406,8 @@ def update_channel(
|
||||
# Opting a channel into full history should give an immediate feed: if we haven't even
|
||||
# fetched its recent uploads yet, do that one channel now (cheap) instead of waiting for
|
||||
# the scheduler. Deep paging still follows on the scheduler's next run (recent-then-deep).
|
||||
# Not for the demo account: it must not be able to trigger an immediate quota-burning backfill
|
||||
# (the scheduler's deep paths are already human-only). Same guard as channel_detail's enrichment.
|
||||
if (
|
||||
deep_turned_on
|
||||
and channel is not None
|
||||
and channel.recent_synced_at is None
|
||||
and not user.is_demo
|
||||
):
|
||||
# (deep_turned_on is only ever True for a non-demo user — see the guard above.)
|
||||
if deep_turned_on and channel is not None and channel.recent_synced_at is None:
|
||||
with quota.attribute(user.id, quota.QuotaAction.VIDEOS_BACKFILL_RECENT):
|
||||
run_recent_backfill(db, [channel], max_channels=1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user