소스 검색

fix: ensure upload subdirectories are created on startup

unknown 19 시간 전
부모
커밋
e020c7bb76
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      backend/main.py

+ 4 - 2
backend/main.py

@@ -152,8 +152,10 @@ async def ws_chat(websocket: WebSocket, token: str = Query(...), order_id: int =
         manager.disconnect(websocket, order_id)
 
 # Mount Static Files
-if not os.path.exists("uploads"):
-    os.makedirs("uploads")
+for sub in ["", "previews", "invoices", "reports"]:
+    path = os.path.join("uploads", sub)
+    if not os.path.exists(path):
+        os.makedirs(path, exist_ok=True)
 # Mount static files for uploads and previews with caching
 app.mount("/uploads", StaticFiles(directory="uploads", html=False), name="uploads")