INNER CODE UNIT · Python
get_cached_file
arnonym/ha-plugins · ha-sip/src/audio_cache.py:11
def get_cached_file(should_cache: bool, cache_dir: Optional[str], file_or_message: cache_type, file_name_or_message: str) -> Optional[str]:
if not should_cache:
return None
if not cache_dir:
log(None, 'Warning: Caching enabled but no cache directory configured.')
return None
file_name = get_cache_file_name(cache_dir, file_or_message, file_name_or_message)
if not os.path.isfile(file_name):
log(None, f'Cache file not found: {file_name}')
return None
log(None, f'Using cache from file: {file_name}')
return file_name
def cache_file(should_cache: bool, cache_dir: Optional[str], file_or_message: cache_type, file_name_or_message: str, file_to_cache: str) -> None:
if not should_cache:
return
if not cache_dir: