@@ -268,80 +268,75 @@ def load_files_for_sending_lazy(files: List[str], workspace: Optional[str] = Non
268268 # Normalize file path
269269 if "\\ " in file_path :
270270 file_path = file_path .replace ("\\ " , "/" )
271-
272- for file_path in files :
273- # Normalize file path
274- if "\\ " in file_path :
275- file_path = file_path .replace ("\\ " , "/" )
276271
277- # Skip directories
278- if os .path .isdir (file_path ):
279- continue
272+ # Skip directories
273+ if os .path .isdir (file_path ):
274+ continue
280275
281- # Handle file path splitting safely
282- if "/" in file_path :
283- _ , name = file_path .rsplit ("/" , 1 )
284- else :
285- name = file_path
276+ # Handle file path splitting safely
277+ if "/" in file_path :
278+ _ , name = file_path .rsplit ("/" , 1 )
279+ else :
280+ name = file_path
286281
287- # Calculate the key name for the form data
288- key = file_path
289- path_stripped = False
282+ # Calculate the key name for the form data
283+ key = file_path
284+ path_stripped = False
290285
291- # If base_paths is provided, try to strip one of the paths from the file path
292- if base_paths :
293- for bp in base_paths :
294- normalized_base_path = bp .rstrip ("/" ) + "/" if not bp .endswith ("/" ) else bp
295- if key .startswith (normalized_base_path ):
296- key = key [len (normalized_base_path ):]
297- path_stripped = True
298- break
299- elif key .startswith (bp .rstrip ("/" )):
300- stripped_base = bp .rstrip ("/" )
301- if key .startswith (stripped_base + "/" ) or key == stripped_base :
302- key = key [len (stripped_base ):]
303- key = key .lstrip ("/" )
304- path_stripped = True
305- break
306- elif base_path :
307- normalized_base_path = base_path .rstrip ("/" ) + "/" if not base_path .endswith ("/" ) else base_path
286+ # If base_paths is provided, try to strip one of the paths from the file path
287+ if base_paths :
288+ for bp in base_paths :
289+ normalized_base_path = bp .rstrip ("/" ) + "/" if not bp .endswith ("/" ) else bp
308290 if key .startswith (normalized_base_path ):
309291 key = key [len (normalized_base_path ):]
310292 path_stripped = True
311- elif key .startswith (base_path .rstrip ("/" )):
312- stripped_base = base_path .rstrip ("/" )
293+ break
294+ elif key .startswith (bp .rstrip ("/" )):
295+ stripped_base = bp .rstrip ("/" )
313296 if key .startswith (stripped_base + "/" ) or key == stripped_base :
314297 key = key [len (stripped_base ):]
315298 key = key .lstrip ("/" )
316299 path_stripped = True
317-
318- # If workspace is provided and no base paths matched, fall back to workspace logic
319- if not path_stripped and workspace and file_path .startswith (workspace ):
320- key = file_path [len (workspace ):]
321- # Remove all leading slashes (for absolute paths)
322- while key .startswith ("/" ):
323- key = key [1 :]
300+ break
301+ elif base_path :
302+ normalized_base_path = base_path .rstrip ("/" ) + "/" if not base_path .endswith ("/" ) else base_path
303+ if key .startswith (normalized_base_path ):
304+ key = key [len (normalized_base_path ):]
324305 path_stripped = True
306+ elif key .startswith (base_path .rstrip ("/" )):
307+ stripped_base = base_path .rstrip ("/" )
308+ if key .startswith (stripped_base + "/" ) or key == stripped_base :
309+ key = key [len (stripped_base ):]
310+ key = key .lstrip ("/" )
311+ path_stripped = True
325312
326- # Clean up relative path prefixes, but preserve filename dots
327- while key .startswith ("./" ):
328- key = key [2 :]
329- while key .startswith ("../" ):
330- key = key [3 :]
331- # Remove any remaining leading slashes (for absolute paths)
313+ # If workspace is provided and no base paths matched, fall back to workspace logic
314+ if not path_stripped and workspace and file_path .startswith (workspace ):
315+ key = file_path [len (workspace ):]
316+ # Remove all leading slashes (for absolute paths)
332317 while key .startswith ("/" ):
333318 key = key [1 :]
319+ path_stripped = True
320+
321+ # Clean up relative path prefixes, but preserve filename dots
322+ while key .startswith ("./" ):
323+ key = key [2 :]
324+ while key .startswith ("../" ):
325+ key = key [3 :]
326+ # Remove any remaining leading slashes (for absolute paths)
327+ while key .startswith ("/" ):
328+ key = key [1 :]
334329
335- # Remove Windows drive letter if present (C:/...)
336- if len (key ) > 2 and key [1 ] == ':' and (key [2 ] == '/' or key [2 ] == '\\ ' ):
337- key = key [2 :]
338- while key .startswith ("/" ):
339- key = key [1 :]
330+ # Remove Windows drive letter if present (C:/...)
331+ if len (key ) > 2 and key [1 ] == ':' and (key [2 ] == '/' or key [2 ] == '\\ ' ):
332+ key = key [2 :]
333+ while key .startswith ("/" ):
334+ key = key [1 :]
340335
341- # Create lazy file loader instead of opening file immediately
342- lazy_file = LazyFileLoader (file_path , key )
343- payload = (key , (key , lazy_file ))
344- send_files .append (payload )
336+ # Create lazy file loader instead of opening file immediately
337+ lazy_file = LazyFileLoader (file_path , key )
338+ payload = (key , (key , lazy_file ))
339+ send_files .append (payload )
345340
346341 log .debug (f"Prepared { len (send_files )} files for lazy loading" )
347342 return send_files
0 commit comments