diff options
| -rw-r--r-- | indra/newview/llconversationlog.cpp | 21 | ||||
| -rw-r--r-- | indra/newview/lllogchat.cpp | 24 | 
2 files changed, 24 insertions, 21 deletions
| diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index 03d1647c5e..4be169e267 100644 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -31,6 +31,8 @@  #include "llnotificationsutil.h"  #include "lltrans.h" +#include "boost/lexical_cast.hpp" +  const int CONVERSATION_LIFETIME = 30; // lifetime of LLConversation is 30 days by spec  struct ConversationParams @@ -382,13 +384,12 @@ bool LLConversationLog::moveLog(const std::string &originDirectory, const std::s  {  	std::string backupFileName; -	UINT backupFileCount = 0; +	unsigned backupFileCount = 0; -	//Does the file exist in the current path -	if(LLFile::isfile(originDirectory)) +	//Does the file exist in the current path, if it does lets move it +	if(LLFile::isfile(originDirectory))   	{ -		 -		//File already exists so make a backup file +		//The target directory contains that file already, so lets store it  		if(LLFile::isfile(targetDirectory))  		{  			backupFileName = targetDirectory + ".backup"; @@ -396,19 +397,15 @@ bool LLConversationLog::moveLog(const std::string &originDirectory, const std::s  			//If needed store backup file as .backup1 etc.  			while(LLFile::isfile(backupFileName))  			{ -				backupFileName = targetDirectory + ".backup"; - -				if(backupFileCount) -				{ -					backupFileName += backupFileCount; -				} +				++backupFileCount; +				backupFileName = targetDirectory + ".backup" + boost::lexical_cast<std::string>(backupFileCount);  			}  			//Rename the file to its backup name so it is not overwritten  			LLFile::rename(targetDirectory, backupFileName);  		} -		//Move the file from the current path to destination path +		//Move the file from the current path to target path  		if(LLFile::rename(originDirectory, targetDirectory) != 0)  		{  			return false; 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); | 
