Add multi-language syntax highlighting to source editor, improve copy button to copy raw file content, and add permission error handling to file API endpoint

This commit is contained in:
2026-03-22 23:52:10 -04:00
parent 6f694148db
commit 1129d1bca5
3 changed files with 76 additions and 9 deletions
+8 -1
View File
@@ -527,7 +527,14 @@ async def api_file(vault_name: str, path: str = Query(..., description="Relative
if not file_path.exists() or not file_path.is_file():
raise HTTPException(status_code=404, detail=f"File not found: {path}")
raw = file_path.read_text(encoding="utf-8", errors="replace")
try:
raw = file_path.read_text(encoding="utf-8", errors="replace")
except PermissionError:
raise HTTPException(status_code=403, detail=f"Permission denied: cannot read file {path}")
except Exception as e:
logger.error(f"Error reading file {path}: {e}")
raise HTTPException(status_code=500, detail=f"Error reading file: {str(e)}")
ext = file_path.suffix.lower()
if ext == ".md":