@@ -157,13 +157,6 @@ async def _forward_frame_request(
157
157
cache_key : str | None = None ,
158
158
cache_ttl : int = 1 ,
159
159
) -> Any :
160
- """
161
- Send HTTP-like request to the frame – first via the agent websocket (“http”
162
- command), otherwise plain HTTP. A small Redis cache (1 s default) is used
163
- for very chatty endpoints like /state.
164
- """
165
-
166
- # 0) maybe serve from cache
167
160
if cache_key and (cached := await redis .get (cache_key )):
168
161
return _bytes_or_json (cached )
169
162
@@ -178,7 +171,6 @@ async def _forward_frame_request(
178
171
else :
179
172
body_for_agent = json .dumps (json_body )
180
173
181
- # 1) agent first --------------------------------------------------------
182
174
if await _use_agent (frame , redis ):
183
175
agent_resp = await http_get_on_frame (
184
176
frame .id ,
@@ -189,7 +181,6 @@ async def _forward_frame_request(
189
181
)
190
182
status , payload = _normalise_agent_response (agent_resp )
191
183
if status == 200 :
192
- # 2a) store in cache ───────────────────────────────────────────
193
184
if cache_key :
194
185
if isinstance (payload , (bytes , bytearray )):
195
186
await redis .set (cache_key , payload , ex = cache_ttl )
@@ -202,7 +193,6 @@ async def _forward_frame_request(
202
193
203
194
raise HTTPException (status_code = 400 , detail = f"Agent error: { status } { payload } " )
204
195
205
- # 2) plain HTTP fallback -------------------------------------------------
206
196
url = _build_frame_url (frame , path , method )
207
197
hdrs = _auth_headers (frame )
208
198
async with httpx .AsyncClient () as client :
@@ -616,13 +606,12 @@ async def api_frame_get_assets(id: int, db: Session = Depends(get_db), redis: Re
616
606
raise HTTPException (status_code = HTTPStatus .NOT_FOUND , detail = "Frame not found" )
617
607
618
608
assets_path = frame .assets_path or "/srv/assets"
619
- # 1) prefer the WebSocket agent
609
+
620
610
if await _use_agent (frame , redis ):
621
611
assets = await assets_list_on_frame (frame .id , assets_path )
622
612
assets .sort (key = lambda a : a ["path" ])
623
613
return {"assets" : assets }
624
614
625
- # 2) legacy SSH fall-back (unchanged)
626
615
ssh = await get_ssh_connection (db , redis , frame )
627
616
try :
628
617
cmd = f"find { assets_path } -type f -exec stat --format='%s %Y %n' {{}} +"
@@ -667,7 +656,6 @@ async def api_frame_assets_upload(
667
656
):
668
657
frame = db .get (Frame , id ) or _not_found ()
669
658
670
- # normalise and validate optional sub-directory
671
659
subdir = (path or "" ).lstrip ("/" )
672
660
if "*" in subdir or ".." in subdir or os .path .isabs (subdir ):
673
661
_bad_request ("Invalid character * in path" )
@@ -681,7 +669,6 @@ async def api_frame_assets_upload(
681
669
682
670
data = await file .read ()
683
671
684
- # one-liner: let remote_exec decide (agent → SSH) and log appropriately
685
672
await upload_file (db , redis , frame , combined_path , data )
686
673
687
674
rel = os .path .relpath (combined_path , assets_path )
0 commit comments