summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2023-09-21 01:07:56 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2023-09-21 01:19:31 +0200
commitd72b43f1a90d271ac6d0b0a398a6f906afb3468c (patch)
treeeadde37d61227636f4369da2b0c99d85b130e735 /indra/newview
parente3096da94bd0a9223d6936c5f2ba011b1922298d (diff)
SL-20287 The 'search_history.txt' file in the user profile is always empty
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llsearchhistory.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/indra/newview/llsearchhistory.cpp b/indra/newview/llsearchhistory.cpp
index 449e0080f0..66e377cb8d 100644
--- a/indra/newview/llsearchhistory.cpp
+++ b/indra/newview/llsearchhistory.cpp
@@ -75,6 +75,17 @@ bool LLSearchHistory::save()
{
// build filename for each user
std::string resolved_filename = getHistoryFilePath();
+
+ // delete the file if it is empty or contains only empty entries
+ if (std::find_if(mSearchHistory.begin(), mSearchHistory.end(), [](const LLSearchHistoryItem& x)
+ {
+ return !x.search_query.empty();
+ }) == mSearchHistory.end())
+ {
+ remove(resolved_filename.c_str());
+ return true;
+ }
+
// open a file for writing
llofstream file(resolved_filename.c_str());
if (!file.is_open())