diff options
Diffstat (limited to 'indra/newview/llnotificationstorage.cpp')
-rwxr-xr-x[-rw-r--r--] | indra/newview/llnotificationstorage.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/indra/newview/llnotificationstorage.cpp b/indra/newview/llnotificationstorage.cpp index 2923221c90..3418b33d37 100644..100755 --- a/indra/newview/llnotificationstorage.cpp +++ b/indra/newview/llnotificationstorage.cpp @@ -103,32 +103,50 @@ bool LLNotificationStorage::writeNotifications(const LLSD& pNotificationData) co return didFileOpen; } -bool LLNotificationStorage::readNotifications(LLSD& pNotificationData) const +bool LLNotificationStorage::readNotifications(LLSD& pNotificationData, bool is_new_filename) const { - LL_INFOS("LLNotificationStorage") << "starting read '" << mFileName << "'" << LL_ENDL; + std::string filename = is_new_filename? mFileName : mOldFileName; + + LL_INFOS("LLNotificationStorage") << "starting read '" << filename << "'" << LL_ENDL; bool didFileRead; pNotificationData.clear(); - llifstream notifyFile(mFileName.c_str()); + llifstream notifyFile(filename.c_str()); didFileRead = notifyFile.is_open(); if (!didFileRead) { - LL_WARNS("LLNotificationStorage") << "Failed to open file '" << mFileName << "'" << LL_ENDL; + LL_WARNS("LLNotificationStorage") << "Failed to open file '" << filename << "'" << LL_ENDL; } else { LLPointer<LLSDParser> parser = new LLSDXMLParser(); didFileRead = (parser->parse(notifyFile, pNotificationData, LLSDSerialize::SIZE_UNLIMITED) >= 0); + notifyFile.close(); + if (!didFileRead) { LL_WARNS("LLNotificationStorage") << "Failed to parse open notifications from file '" << mFileName - << "'" << LL_ENDL; + << "'" << LL_ENDL; + LLFile::remove(filename); + LL_WARNS("LLNotificationStorage") << "Removed invalid open notifications file '" << mFileName + << "'" << LL_ENDL; + } + } + + if (!didFileRead) + { + if(is_new_filename) + { + didFileRead = readNotifications(pNotificationData, false); + if(didFileRead) + { + writeNotifications(pNotificationData); + LLFile::remove(mOldFileName); + } } } - - LL_INFOS("LLNotificationStorage") << "ending read '" << mFileName << "'" << LL_ENDL; return didFileRead; } |