fix(downloads): second-round review fixes (fork on re-download, title fallbacks)
- redownload now ALWAYS rebuilds into a fresh private asset instead of ever reusing a shared cached file: the cache sig is salted with job_id + current asset_id, so the fork is distinct from both the dedup pool and the job's own current asset. This resolves the co-held silent no-op (finding #1) — a shared asset is left intact for its other holders while THIS job re-fetches its own copy. Resolving the fork BEFORE releasing the old hold (and the unique salted key) also removes the IntegrityError-rollback-after-file-delete window (finding #2). - format_sig gains an optional `salt` for that fork identity. - titles: don't consume the space after `|`, so a "stats | #hashtags" remainder keeps the leading whitespace _TRAILING_HASHTAGS needs — and fall back to the prefix+hashtag-stripped text, so neither the stats nor the SEO hashtags are resurrected when a title empties (#3). - worker: early-fill asset.title falls back to the video id so a title that cleaned to empty doesn't show a blank card while downloading (#5). - Tests for the salt fork and the hashtag-remainder case. (Finding #4 — quota on re-download — intentionally not changed: a re-download reuses the existing job and re-fetches ~the same bytes, so calling check_enqueue would wrongly reject on the job-count cap while footprint is unchanged.)
This commit is contained in:
@@ -17,6 +17,16 @@ def test_mp4_default_selects_avc1_with_progressive_fallback():
|
||||
assert fmt.endswith("bestvideo+bestaudio/best")
|
||||
|
||||
|
||||
def test_format_sig_salt_forks_a_distinct_identity():
|
||||
spec = {"mode": "av", "container": "mp4", "max_height": 720}
|
||||
base = formats.format_sig(spec)
|
||||
# A salt yields a distinct cache identity (force-redownload's private-asset fork); different
|
||||
# salts differ from each other and from the unsalted sig, same salt is stable.
|
||||
assert formats.format_sig(spec, salt="7:12") != base
|
||||
assert formats.format_sig(spec, salt="7:12") != formats.format_sig(spec, salt="7:13")
|
||||
assert formats.format_sig(spec, salt="7:12") == formats.format_sig(spec, salt="7:12")
|
||||
|
||||
|
||||
def test_mp4_default_keeps_h264_sort_tiebreaker():
|
||||
sort = _opts({"mode": "av", "container": "mp4"})["format_sort"]
|
||||
assert "vcodec:h264" in sort and "acodec:aac" in sort
|
||||
|
||||
Reference in New Issue
Block a user