diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 4854f44e03..fec5a1a02b 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -274,7 +274,7 @@ store(BamCacheRecord *record) { temp_file.close(); // Now move the file into place. - if (!temp_pathname.rename_to(cache_pathname)) { + if (!temp_pathname.rename_to(cache_pathname) && temp_pathname.exists()) { cache_pathname.unlink(); if (!temp_pathname.rename_to(cache_pathname)) { util_cat.error()