fix(storage): resolve correct backend_root for uploads directory to match Nginx alias

This commit is contained in:
adithiyan 2026-10-30 10:27:15 +05:30
parent 3d05d0533b
commit 0a46f77412
2 changed files with 21 additions and 4 deletions

View file

@ -37,8 +37,16 @@ router = APIRouter(
) )
from pathlib import Path from pathlib import Path
project_root = Path(__file__).resolve().parents[4] curr = Path(__file__).resolve()
UPLOAD_DIR = str(project_root / "uploads" / "migrations") backend_root = None
for p in curr.parents:
if (p / "app").is_dir():
backend_root = p
break
if not backend_root:
backend_root = curr.parents[4]
UPLOAD_DIR = str(backend_root / "uploads" / "migrations")
os.makedirs(UPLOAD_DIR, exist_ok=True) os.makedirs(UPLOAD_DIR, exist_ok=True)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View file

@ -7,8 +7,17 @@ from typing import Tuple, Dict, Any, Optional
from app.models.MigrationModel import MediaItemStatusEnum from app.models.MigrationModel import MediaItemStatusEnum
project_root = Path(__file__).resolve().parents[4] # Resolve backend root (the folder containing 'app' and 'uploads')
MIGRATION_BASE_DIR = str(project_root / "uploads" / "migrations") curr = Path(__file__).resolve()
backend_root = None
for p in curr.parents:
if (p / "app").is_dir():
backend_root = p
break
if not backend_root:
backend_root = curr.parents[3]
MIGRATION_BASE_DIR = str(backend_root / "uploads" / "migrations")
os.makedirs(MIGRATION_BASE_DIR, exist_ok=True) os.makedirs(MIGRATION_BASE_DIR, exist_ok=True)
class StorageManager: class StorageManager: