auto-save 2026-05-13 12:40 (~4)

This commit is contained in:
2026-05-13 12:40:56 +08:00
parent b5ae3e7b6d
commit 95b1354f9f
4 changed files with 64 additions and 3 deletions

View File

@@ -1087,6 +1087,28 @@ def get_cleaned_frame(job_id: str, idx: int):
return FileResponse(p, media_type="image/jpeg")
@app.delete("/jobs/{job_id}/frames/{idx}/cleanup", response_model=Job)
def discard_cleaned(job_id: str, idx: int) -> Job:
"""丢弃待应用的清洗版(不影响已应用的)"""
job = JOBS.get(job_id)
if not job:
raise HTTPException(404, "job not found")
frame = next((f for f in job.frames if f.index == idx), None)
if not frame:
raise HTTPException(404, "frame not found")
p = job_dir(job_id) / "cleaned" / f"{idx:03d}.jpg"
if p.exists():
try: p.unlink()
except OSError: pass
new_frames = []
for f in job.frames:
if f.index == idx:
f.cleaned_url = None
new_frames.append(f)
update(job, frames=new_frames, message=f"丢弃清洗版 · 分镜 {idx + 1}")
return job
@app.post("/jobs/{job_id}/frames/{idx}/cleanup/apply", response_model=Job)
def apply_cleaned(job_id: str, idx: int) -> Job:
"""用清洗版替换原关键帧:物理覆盖 frames/{idx}.jpg ← cleaned/{idx}.jpg。