Skip to content

Commit 57ddb7f

Browse files
authored
Fix: filter hidden files from /internal/files endpoint (#11191)
1 parent 17c92a9 commit 57ddb7f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

api_server/routes/internal/internal_routes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ async def get_files(request: web.Request) -> web.Response:
5858
return web.json_response({"error": "Invalid directory type"}, status=400)
5959

6060
directory = get_directory_by_type(directory_type)
61+
62+
def is_visible_file(entry: os.DirEntry) -> bool:
63+
"""Filter out hidden files (e.g., .DS_Store on macOS)."""
64+
return entry.is_file() and not entry.name.startswith('.')
65+
6166
sorted_files = sorted(
62-
(entry for entry in os.scandir(directory) if entry.is_file()),
67+
(entry for entry in os.scandir(directory) if is_visible_file(entry)),
6368
key=lambda entry: -entry.stat().st_mtime
6469
)
6570
return web.json_response([entry.name for entry in sorted_files], status=200)

0 commit comments

Comments
 (0)