Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exceptions getting cache directory when MemoryTempfile fails (i.e. in a chroot) #58

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions ovos_utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ def get_temp_path(*args):
def get_cache_directory(folder):
# optional import to use ram for cache
# does not work in windows!
try:
from memory_tempfile import MemoryTempfile
except ImportError:
MemoryTempfile = None
if os.name == 'nt' or not MemoryTempfile:
path = get_temp_path(folder)
else:
path = join(MemoryTempfile(fallback=True).gettempdir(), folder)
path = get_temp_path(folder)
if os.name != 'nt':
try:
from memory_tempfile import MemoryTempfile
path = join(MemoryTempfile(fallback=True).gettempdir(), folder)
except ImportError:
pass
except Exception as e:
LOG.exception(e)
os.makedirs(path, exist_ok=True)
return path

Expand Down