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:
@@ -68,3 +68,11 @@ def test_engagement_only_title_does_not_resurrect_the_stats():
|
||||
out = normalize_title("1.6M views · 66K reactions |")
|
||||
assert out == ""
|
||||
assert "views" not in (out or "") and "reactions" not in (out or "")
|
||||
|
||||
|
||||
def test_prefix_plus_only_hashtags_resurrects_neither_stats_nor_hashtags():
|
||||
# stats prefix + trailing SEO hashtags → both are removed; the fallback must not bring back the
|
||||
# hashtags that rule 2 strips (nor the stats prefix).
|
||||
out = normalize_title("5 views | #foo #bar")
|
||||
assert out == ""
|
||||
assert "#foo" not in (out or "") and "views" not in (out or "")
|
||||
|
||||
Reference in New Issue
Block a user