summaryrefslogtreecommitdiff
path: root/indra/newview/lllogchat.cpp
diff options
context:
space:
mode:
authorGilbert Gonzales <gilbert@lindenlab.com>2013-02-25 16:48:09 -0800
committerGilbert Gonzales <gilbert@lindenlab.com>2013-02-25 16:48:09 -0800
commit084ea74d43471eec1ae8781c4946fcf2a3a76a78 (patch)
tree4dd95e9f250b058307bbe9eec9f156e912b489b1 /indra/newview/lllogchat.cpp
parent57935506c29e4dfde82626a91a853d87a46aead3 (diff)
CHUI-778: Now when conversation log and trascript files are moved they will not overwrite prior files with the same name. Instead the prior files will be stored as *.backup.
Diffstat (limited to 'indra/newview/lllogchat.cpp')
-rw-r--r--indra/newview/lllogchat.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index d9d28c6d70..6562cfe1bb 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -509,9 +509,12 @@ bool LLLogChat::moveTranscripts(const std::string originDirectory,
{
std::string newFullPath;
bool movedAllTranscripts = true;
+ std::string backupFileName;
+ unsigned backupFileCount;
BOOST_FOREACH(const std::string& fullpath, listOfFilesToMove)
{
+ backupFileCount = 0;
newFullPath = targetDirectory + fullpath.substr(originDirectory.length(), std::string::npos);
S32 retry_count = 0;
@@ -525,17 +528,20 @@ bool LLLogChat::moveTranscripts(const std::string originDirectory,
LL_WARNS("LLLogChat::moveTranscripts") << "Problem renaming " << fullpath << " - errorcode: "
<< result << " attempt " << retry_count << LL_ENDL;
- if(retry_count >= 5)
- {
- LL_WARNS("LLLogChat::moveTranscripts") << "Failed to rename " << fullpath << LL_ENDL;
- return false;
- }
-
- //If the file already exists in the new location, remove it then try again
+ //The target directory contains that file already, so lets store it
if(LLFile::isfile(newFullPath))
{
- LLFile::remove(newFullPath);
- LL_WARNS("LLLogChat::moveTranscripts") << "File already exists " << fullpath << LL_ENDL;
+ backupFileName = newFullPath + ".backup";
+
+ //If needed store backup file as .backup1 etc.
+ while(LLFile::isfile(backupFileName))
+ {
+ ++backupFileCount;
+ backupFileName = newFullPath + ".backup" + boost::lexical_cast<std::string>(backupFileCount);
+ }
+
+ //Rename the file to its backup name so it is not overwritten
+ LLFile::rename(newFullPath, backupFileName);
}
ms_sleep(100);