fix(downloads): a converted upload too big says so, and a suspended owner's waiting rebuild is not "preparing"
- A converted upload over the space left (not zero) fails with CONVERTED_TOO_BIG_MESSAGE, not "storage is full"; it classifies as quota_exceeded by the phrase it shares with the clip's. - The public watch page says "preparing" only for a job a worker will take: a suspended owner's queued job waits for as long as the suspension lasts, so the link says the video is gone, as for a paused rebuild. - The worker's claim docstring names the restart case: a running job put back in the queue waits.
This commit is contained in:
@@ -15,6 +15,7 @@ import pytest
|
||||
|
||||
from app import sysconfig
|
||||
from app.config import settings
|
||||
from app.downloads import errors as dlerrors
|
||||
from app.downloads import gc as gcmod
|
||||
from app.downloads import pipeline, quota, storage
|
||||
from app.downloads import probe as probemod
|
||||
@@ -124,6 +125,8 @@ def test_a_conversion_that_outgrows_the_cap_is_refused_and_keeps_the_original(
|
||||
db.expire_all()
|
||||
job = db.get(DownloadJob, job.id)
|
||||
assert (job.status, job.error_code) == ("error", "quota_exceeded")
|
||||
# 90 of the 100 are still free: the converted file is too big, the storage is not full.
|
||||
assert job.error == dlerrors.CONVERTED_TOO_BIG_MESSAGE
|
||||
assert original.exists()
|
||||
assert [p.name for p in _uploads_dir(_root, u.id).iterdir()] == [original.name]
|
||||
|
||||
@@ -558,6 +561,33 @@ def test_a_link_says_preparing_only_while_its_video_is_being_made(
|
||||
assert r.json()["detail"]["reason"] == reason
|
||||
|
||||
|
||||
def test_a_link_to_a_suspended_owners_waiting_rebuild_says_it_is_gone(
|
||||
db, as_user, make_user, _root, monkeypatch, upload_headers
|
||||
):
|
||||
# The worker leaves a suspended user's queued jobs where they are, maybe for good: like a paused
|
||||
# rebuild, nothing is making the video, so "try again shortly" would never come true.
|
||||
_probe(monkeypatch, vcodec="h264")
|
||||
owner = make_user()
|
||||
c = as_user(owner)
|
||||
job = c.post(
|
||||
"/api/downloads/upload", content=b"h264 bytes", headers=upload_headers("clip.mp4")
|
||||
).json()
|
||||
link = c.post(f"/api/downloads/{job['id']}/links", json={"allow_download": False}).json()
|
||||
db.get(MediaAsset, job["asset"]["id"]).status = "pending"
|
||||
db.get(DownloadJob, job["id"]).status = "queued"
|
||||
owner.is_suspended = True
|
||||
db.commit()
|
||||
r = c.get(f"/api/public/watch/{link['token']}")
|
||||
assert r.status_code == 404
|
||||
assert r.json()["detail"]["reason"] == "video_gone"
|
||||
# A rebuild already running when the owner was suspended still finishes.
|
||||
db.get(DownloadJob, job["id"]).status = "running"
|
||||
db.commit()
|
||||
assert c.get(f"/api/public/watch/{link['token']}").json()["detail"]["reason"] == (
|
||||
"video_preparing"
|
||||
)
|
||||
|
||||
|
||||
def test_the_admin_storage_view_counts_a_waiting_upload(db, as_user, make_user, _root, monkeypatch):
|
||||
# The same disk the owner's footprint and the GC's cap count (`quota.ON_DISK`).
|
||||
_probe(monkeypatch)
|
||||
|
||||
Reference in New Issue
Block a user