Avinashnalla7 commited on
Commit
af7a9e0
·
1 Parent(s): 581704a

debug: add /api/sftp-test

Browse files
Files changed (1) hide show
  1. backend/api.py +12 -0
backend/api.py CHANGED
@@ -224,3 +224,15 @@ def jobs_status(job_id: str, req: StatusReq, x_worker_token: Optional[str] = Hea
224
  job.status = req.status
225
  job.message = req.message
226
  return {"ok": True, "job_id": job_id, "status": job.status}
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  job.status = req.status
225
  job.message = req.message
226
  return {"ok": True, "job_id": job_id, "status": job.status}
227
+
228
+
229
+ @app.get("/api/sftp-test")
230
+ def api_sftp_test():
231
+ # returns quickly if SFTP reachable, otherwise errors/timeout
232
+ try:
233
+ # reuse download_bytes to avoid duplication (reads tiny path)
234
+ # list isn't implemented here, so just try to fetch a known-nonexistent file and ensure it errors fast
235
+ download_bytes("does_not_exist.txt")
236
+ return {"ok": True, "note": "unexpectedly read file"}
237
+ except Exception as e:
238
+ return {"ok": False, "error": str(e)[:200]}