From ffc6a1512d6e66e6811722c7be46f436b62ab238 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 21 May 2022 02:14:44 +0200 Subject: [PATCH] do not follow symlinks --- music_assistant/controllers/music/providers/filesystem.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/music_assistant/controllers/music/providers/filesystem.py b/music_assistant/controllers/music/providers/filesystem.py index 0450a13e..b4e35717 100644 --- a/music_assistant/controllers/music/providers/filesystem.py +++ b/music_assistant/controllers/music/providers/filesystem.py @@ -43,9 +43,13 @@ from music_assistant.models.provider import MusicProvider async def scantree(path: str) -> AsyncGenerator[os.DirEntry, None]: """Recursively yield DirEntry objects for given directory.""" + + def is_dir(entry: os.DirEntry) -> bool: + return entry.is_dir(follow_symlinks=False) + loop = asyncio.get_running_loop() for entry in await loop.run_in_executor(None, os.scandir, path): - if await loop.run_in_executor(None, entry.is_dir): + if await loop.run_in_executor(None, is_dir, entry): async for subitem in scantree(entry.path): yield subitem else: -- 2.34.1