diff options
author | Ansariel Hiller <ansarielhiller@yahoo.de> | 2021-06-09 23:30:25 +0000 |
---|---|---|
committer | Callum Linden <callum@lindenlab.com> | 2021-06-09 23:30:25 +0000 |
commit | 81ebdfd755f967e900b69d47064ff89be248945b (patch) | |
tree | 0336befe2a5cd50812893a411156fa64918035cf | |
parent | ad9ed0a94dfd37878b35b70e0a365017a1e548bf (diff) | |
parent | 4c558e85bd90d77696e9201b8996272176d7adc5 (diff) |
Merged in DRTVWR-519 (pull request #594)
Fix more crashes in disk cache due to boost error handling
Approved-by: Callum Linden
-rw-r--r-- | indra/llfilesystem/lldiskcache.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 905351886f..f4d20d0e61 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -253,9 +253,15 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) // current time const std::time_t cur_time = std::time(nullptr); + boost::system::error_code ec; #if LL_WINDOWS // file last write time - const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path)); + const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec); + if (ec.failed()) + { + LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL; + return; + } // delta between cur time and last time the file was written const std::time_t delta_time = cur_time - last_write_time; @@ -264,11 +270,16 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) // before the last one if (delta_time > time_threshold) { - boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time); + boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec); } #else // file last write time - const std::time_t last_write_time = boost::filesystem::last_write_time(file_path); + const std::time_t last_write_time = boost::filesystem::last_write_time(file_path, ec); + if (ec.failed()) + { + LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL; + return; + } // delta between cur time and last time the file was written const std::time_t delta_time = cur_time - last_write_time; @@ -277,9 +288,14 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) // before the last one if (delta_time > time_threshold) { - boost::filesystem::last_write_time(file_path, cur_time); + boost::filesystem::last_write_time(file_path, cur_time, ec); } #endif + + if (ec.failed()) + { + LL_WARNS() << "Failed to update last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL; + } } const std::string LLDiskCache::getCacheInfo() |