From: Marcel van der Veldt Date: Sat, 29 Mar 2025 11:31:20 +0000 (+0100) Subject: Fix: Prefer /tmp is not running as add-on X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=629453d7a1b0d85cefc63343ce01c052779509ed;p=music-assistant-server.git Fix: Prefer /tmp is not running as add-on --- diff --git a/music_assistant/controllers/streams.py b/music_assistant/controllers/streams.py index c2a16d01..91507684 100644 --- a/music_assistant/controllers/streams.py +++ b/music_assistant/controllers/streams.py @@ -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