Fix: always check if cache path (still) exists
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 16 Mar 2025 08:33:21 +0000 (09:33 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 16 Mar 2025 08:33:21 +0000 (09:33 +0100)
music_assistant/helpers/audio.py

index 3208e30f7a7827a4904f8d6ec209d6a7e9ee7232..52209c59de93d2c90219641b813504c6966eff8c 100644 (file)
@@ -97,14 +97,14 @@ class StreamCache:
             # cache file already exists
             return
         # use cache controller to store the translation of uri-->cache file
-        if stored_cache_file := await self.mass.cache.get(
-            self.streamdetails.uri, base_key="audiocache"
-        ):
+        if (
+            stored_cache_file := await self.mass.cache.get(
+                self.streamdetails.uri, base_key="audiocache"
+            )
+        ) and await asyncio.to_thread(os.path.exists, stored_cache_file):
             # cache file already exists in memory
             self._cache_file = stored_cache_file
-            if await asyncio.to_thread(os.path.exists, self._cache_file):
-                # cache file already exists
-                return
+            return
         else:
             # create new cache file
             cache_id = shortuuid.random(30)