Skip to content
Snippets Groups Projects
Commit 81ebdfd7 authored by Ansariel Hiller's avatar Ansariel Hiller Committed by Callum Linden
Browse files

Merged in DRTVWR-519 (pull request #594)

Fix more crashes in disk cache due to boost error handling

Approved-by: Callum Linden
parents ad9ed0a9 4c558e85
No related branches found
No related tags found
No related merge requests found
...@@ -253,9 +253,15 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) ...@@ -253,9 +253,15 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path)
// current time // current time
const std::time_t cur_time = std::time(nullptr); const std::time_t cur_time = std::time(nullptr);
boost::system::error_code ec;
#if LL_WINDOWS #if LL_WINDOWS
// file last write time // 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 // delta between cur time and last time the file was written
const std::time_t delta_time = cur_time - last_write_time; const std::time_t delta_time = cur_time - last_write_time;
...@@ -264,11 +270,16 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) ...@@ -264,11 +270,16 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path)
// before the last one // before the last one
if (delta_time > time_threshold) 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 #else
// file last write time // 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 // delta between cur time and last time the file was written
const std::time_t delta_time = cur_time - last_write_time; const std::time_t delta_time = cur_time - last_write_time;
...@@ -277,9 +288,14 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) ...@@ -277,9 +288,14 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path)
// before the last one // before the last one
if (delta_time > time_threshold) 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 #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() const std::string LLDiskCache::getCacheInfo()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment