fix: handle permission errors when browsing directories
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 2m11s
Run Tests / Backend Tests (push) Failing after 5m47s
Run Tests / Frontend Tests (push) Failing after 1m30s
Run Tests / Test Summary (push) Failing after 14s
Run Tests / Frontend Tests (pull_request) Failing after 2m20s
Run Tests / Test Summary (pull_request) Failing after 18s
Run Tests / Backend Tests (pull_request) Failing after 4m9s
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 2m11s
Run Tests / Backend Tests (push) Failing after 5m47s
Run Tests / Frontend Tests (push) Failing after 1m30s
Run Tests / Test Summary (push) Failing after 14s
Run Tests / Frontend Tests (pull_request) Failing after 2m20s
Run Tests / Test Summary (pull_request) Failing after 18s
Run Tests / Backend Tests (pull_request) Failing after 4m9s
This commit is contained in:
@@ -66,8 +66,18 @@ def browse(path: str = ""):
|
||||
target = _safe_path(path)
|
||||
except ValueError:
|
||||
raise HTTPException(status_code=403, detail="Access denied")
|
||||
|
||||
# Check if we have permission to read the directory
|
||||
try:
|
||||
items = list(target.iterdir())
|
||||
except PermissionError:
|
||||
raise HTTPException(status_code=403, detail="Permission denied")
|
||||
except OSError as e:
|
||||
logger.error(f"Error reading directory {target}: {e}")
|
||||
raise HTTPException(status_code=500, detail="Error reading directory")
|
||||
|
||||
entries = []
|
||||
for item in sorted(target.iterdir()):
|
||||
for item in sorted(items):
|
||||
try:
|
||||
if not _is_safe_symlink(item):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user