From 39e5c8633e84dc7d6abe308e4cabc3db2882bd99 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Tue, 18 May 2021 21:26:54 -0400 Subject: [PATCH] Fix crashing on failure to boost::filesystem::remove --- indra/llfilesystem/lldir.cpp | 14 ++++++++++++-- indra/llfilesystem/lldiskcache.cpp | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index f7c2e0678ff..85563b38df1 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -207,11 +207,21 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) { if (!boost::filesystem::is_empty (dir_path)) { // Directory has content - num_deleted = boost::filesystem::remove_all (dir_path); + boost::system::error_code ec; + num_deleted = boost::filesystem::remove_all(dir_path, ec); + if (ec.failed()) + { + LL_WARNS() << "Failed to delete file " << dir_path << ": " << ec.message() << LL_ENDL; + } } else { // Directory is empty - boost::filesystem::remove (dir_path); + boost::system::error_code ec; + num_deleted = boost::filesystem::remove(dir_path, ec); + if (ec.failed()) + { + LL_WARNS() << "Failed to delete folder " << dir_path << ": " << ec.message() << LL_ENDL; + } } } } diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 5993de532ba..43dca2f345f 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -113,7 +113,12 @@ void LLDiskCache::purge() if (file_size_total > mMaxSizeBytes) { remove_file = true; - boost::filesystem::remove(entry.second.second); + boost::system::error_code ec; + boost::filesystem::remove(entry.second.second, ec); + if (ec.failed()) + { + LL_WARNS() << "Failed to delete cached file " << entry.second.second << ": " << ec.message() << LL_ENDL; + } } if (mEnableCacheDebugInfo) @@ -220,7 +225,12 @@ void LLDiskCache::clearCache() #endif if (boost::filesystem::is_directory(cache_path)) { - boost::filesystem::remove_all(cache_path); + boost::system::error_code ec; + boost::filesystem::remove_all(cache_path, ec); + if (ec.failed()) + { + LL_WARNS() << "Failed to delete cached files " << cache_path << ": " << ec.message() << LL_ENDL; + } createCache(); } -- GitLab