Fix: Prefer /tmp is not running as add-on
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 29 Mar 2025 11:31:20 +0000 (12:31 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 29 Mar 2025 11:31:20 +0000 (12:31 +0100)
music_assistant/controllers/streams.py

index c2a16d016d5e1bfd175a53fc3896127b0465985a..915076845ada383f3317464014aaaaa521df080d 100644 (file)
@@ -250,12 +250,11 @@ class StreamsController(CoreController):
         FFMPEG_LOGGER.setLevel(self.logger.level)
         # perform check for ffmpeg version
         await check_ffmpeg_version()
-        # select a folder to store temporary audio cache files
-        # note that on HAOS we run /tmp in tmpfs so we need
-        # to pick another temporary location which is not /tmp
-        # we prefer the root/user dir because on the docker install
-        # it will be cleaned up on a reboot
-        self._audio_cache_dir = os.path.join(os.path.expanduser("~"), ".audio")
+        if self.mass.running_as_hass_addon:
+            # When running as HAOS add-on, we run /tmp as tmpfs so we need
+            # to pick another temporary location which is not /tmp.
+            # We prefer the root/user dir because it will be cleaned up on a reboot
+            self._audio_cache_dir = os.path.join(os.path.expanduser("~"), ".audio")
         if not await asyncio.to_thread(os.path.isdir, self._audio_cache_dir):
             await asyncio.to_thread(os.makedirs, self._audio_cache_dir)
         # enable cache by default if we have enough free space only