From 1c357f32cae2576bf33116ee58619e57d3aff65d Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Feb 2020 15:08:05 +0100 Subject: [PATCH] putil: fix asserts when model-cache-dir cannot be created Fixes #790 --- panda/src/express/virtualFileSystem.cxx | 3 +-- panda/src/putil/bamCache.cxx | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index eda84c4075..1e279fc2c4 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -497,8 +497,7 @@ make_directory_full(const Filename &filename) { // Now make the last one, and check the return value. PT(VirtualFile) result = do_get_file(filename, OF_make_directory); _lock.unlock(); - nassertr_always(result != nullptr, false); - return result->is_directory(); + return (result != nullptr) ? result->is_directory() : false; } /** diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 4dbcf06966..88f993825b 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -133,10 +133,16 @@ set_root(const Filename &root) { delete _index; _index = new BamCacheIndex; _index_stale_since = 0; + + if (!vfs->is_directory(_root)) { + util_cat.error() + << "Unable to make directory " << _root << ", caching disabled.\n"; + _active = false; + return; + } + read_index(); check_cache_size(); - - nassertv(vfs->is_directory(_root)); } /**