-
Notifications
You must be signed in to change notification settings - Fork 0
fix(upload): normalize Windows separators before basename extraction #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
efc022a
340e03e
aba9b8c
2abeab6
3e3fff0
a7d2fbc
50fcb88
5417e24
afd9762
2aa243b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -797,13 +797,28 @@ def _run_job( | |
| cleanup_temp_dir(temp_dir_path) | ||
|
|
||
|
|
||
| def _cleanup_expired_jobs() -> None: | ||
| """Remove jobs and their temporary workspaces that have been finished for over 24 hours.""" | ||
| from datetime import timedelta | ||
| store = _get_job_store() | ||
| now = _now() | ||
| for job in store.list_jobs(): | ||
| if job["status"] in ("done", "failed"): | ||
| try: | ||
| updated_at = datetime.fromisoformat(job["updated_at"]) | ||
| if now - updated_at > timedelta(hours=24): | ||
| _cleanup_job(job["id"]) | ||
| except Exception: | ||
| logger.exception("Failed to parse updated_at for job %s", job["id"]) | ||
|
|
||
| @app.post("/jobs") | ||
| def submit_job( | ||
| background_tasks: BackgroundTasks, | ||
| file: UploadFile = File(...), | ||
| target_bytes: int = Form(2_000_000_000), | ||
| ): | ||
| """Enqueue a shrink job and return its id for asynchronous status polling.""" | ||
| background_tasks.add_task(_cleanup_expired_jobs) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 실패한 정리 작업이 요청 처리와 작업 실행을 막지 않도록 분리하세요. 현재 정리 작업이 잘못된 요청에도 등록되고 📍 Affects 1 file
🤖 Prompt for AI Agents |
||
| error = _validate_request(file, target_bytes) | ||
| if error is not None: | ||
| return JSONResponse(status_code=400, content={"error": error}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: ContextualWisdomLab/codec-carver
Length of output: 170
🏁 Script executed:
Repository: ContextualWisdomLab/codec-carver
Length of output: 31694
🏁 Script executed:
Repository: ContextualWisdomLab/codec-carver
Length of output: 7854
정리 성공 후 작업 레코드를 삭제하세요.
cleanup_temp_dir()는shutil.rmtree(..., ignore_errors=True)로 삭제 오류를 무시합니다._cleanup_job()은 그 전에store.delete(job_id)를 호출하므로, 디렉터리 삭제에 실패해도 레코드가 사라져 재시도할 수 없습니다. 삭제 성공 여부를 반환하거나 오류를 전달하고, 성공한 경우에만store.delete(job_id)를 호출하세요.🤖 Prompt for AI Agents