Selaa lähdekoodia

fix: ensure upload subdirectories are created on startup

unknown 20 tuntia sitten
vanhempi
commit
e020c7bb76
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  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")