Fix relative path

This commit is contained in:
dvirlabs 2025-08-03 01:29:17 +00:00
parent 84c738632b
commit 994c74b136
3 changed files with 10 additions and 2 deletions

View File

@ -1,2 +1,2 @@
MUSIC_DIR=/root/tunedrop/backend/music MUSIC_DIR=music/
NAVIDROME_SCAN_URL= NAVIDROME_SCAN_URL=

View File

@ -4,7 +4,15 @@ from dotenv import load_dotenv
load_dotenv() load_dotenv()
class Settings: class Settings:
MUSIC_DIR = os.getenv("MUSIC_DIR", "/root/tunedrop/backend/music") # If MUSIC_DIR is not absolute, make it relative to the project root
_music_dir = os.getenv("MUSIC_DIR", "music")
if not os.path.isabs(_music_dir):
# Use the directory where config.py is located as the base
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
MUSIC_DIR = os.path.abspath(os.path.join(BASE_DIR, _music_dir))
else:
MUSIC_DIR = _music_dir
NAVIDROME_SCAN_URL = os.getenv("NAVIDROME_SCAN_URL", "") NAVIDROME_SCAN_URL = os.getenv("NAVIDROME_SCAN_URL", "")
settings = Settings() settings = Settings()