Skip to content
Snippets Groups Projects
Commit caf7585a authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix crash on diskcache purge

parent ab186580
Branches
Tags
No related merge requests found
...@@ -113,7 +113,10 @@ void LLDiskCache::purge() ...@@ -113,7 +113,10 @@ void LLDiskCache::purge()
#endif #endif
if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed())
{ {
for (auto& entry : boost::make_iterator_range(boost::filesystem::recursive_directory_iterator(cache_path), {})) boost::filesystem::recursive_directory_iterator dir_iter(cache_path, ec);
if (!ec.failed())
{
for (auto& entry : boost::make_iterator_range(dir_iter, {}))
{ {
ec.clear(); ec.clear();
if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed()) if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
...@@ -138,6 +141,7 @@ void LLDiskCache::purge() ...@@ -138,6 +141,7 @@ void LLDiskCache::purge()
} }
} }
} }
}
std::sort(file_info.begin(), file_info.end(), [](const file_info_t& x, const file_info_t& y) std::sort(file_info.begin(), file_info.end(), [](const file_info_t& x, const file_info_t& y)
{ {
...@@ -176,6 +180,7 @@ void LLDiskCache::purge() ...@@ -176,6 +180,7 @@ void LLDiskCache::purge()
if (ec.failed()) if (ec.failed())
{ {
LL_WARNS() << "Failed to delete cache file " << entry.second.second << ": " << ec.message() << LL_ENDL; LL_WARNS() << "Failed to delete cache file " << entry.second.second << ": " << ec.message() << LL_ENDL;
continue;
} }
} }
} }
...@@ -414,7 +419,10 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir) ...@@ -414,7 +419,10 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir)
#endif #endif
if (boost::filesystem::is_directory(dir_path, ec) && !ec.failed()) if (boost::filesystem::is_directory(dir_path, ec) && !ec.failed())
{ {
for (auto& entry : boost::make_iterator_range(boost::filesystem::recursive_directory_iterator(dir_path), {})) boost::filesystem::recursive_directory_iterator dir_iter(dir_path,ec);
if (!ec.failed())
{
for (auto& entry : boost::make_iterator_range(dir_iter, {}))
{ {
ec.clear(); ec.clear();
if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed()) if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
...@@ -432,6 +440,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir) ...@@ -432,6 +440,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir)
} }
} }
} }
}
return total_file_size; return total_file_size;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment