mirror of
https://github.com/blw1138/cross-py-builder.git
synced 2026-09-07 21:41:09 -05:00
Fix disappearing artifacts and guard against empty builds
The agent's background build threads called jsonify()/send_file() with no Flask app context, so after a successful build they crashed with 'Working outside of application context', which triggered the error handler that rmtree'd the whole build dir before the controller could download the artifact. Wrap both runners in app.app_context(). Also guard all three layers against empty results: the agent refuses to report success or serve a zip when dist/ has no files, and the scheduler flags a downloaded empty zip as a failure rather than marking the job done.
This commit is contained in:
@@ -3,6 +3,7 @@ import logging
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
import zipfile
|
||||
|
||||
import requests
|
||||
|
||||
@@ -225,6 +226,12 @@ class Scheduler:
|
||||
for chunk in resp.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
|
||||
with zipfile.ZipFile(dest) as zf:
|
||||
files = [n for n in zf.namelist() if not n.endswith("/")]
|
||||
if not files:
|
||||
os.remove(dest)
|
||||
raise RuntimeError(f"Worker {worker['url']} returned an empty artifact zip for {worker_job_id}")
|
||||
|
||||
db.update_job(job_id, artifacts=[fname])
|
||||
|
||||
# ---- logging / status -------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user