X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fmessagelistinserter.cpp;h=e0d8957c3deafac5354e6e9a652c19fd9c4f0ea4;hb=9a14c0d9f7f7c319e539583b93664953764e83b7;hp=6fda2443dbbc419a1982285ded48b7e32834d4a0;hpb=14fff12d9df0ee30e2df4bf9d22c2e83065816df;p=fms.git diff --git a/src/freenet/messagelistinserter.cpp b/src/freenet/messagelistinserter.cpp index 6fda244..e0d8957 100644 --- a/src/freenet/messagelistinserter.cpp +++ b/src/freenet/messagelistinserter.cpp @@ -24,6 +24,7 @@ void MessageListInserter::CheckForNeededInsert() std::string sql; DateTime now; DateTime previous; + bool startedinsert=false; now.SetToGMTime(); previous.SetToGMTime(); @@ -41,11 +42,12 @@ void MessageListInserter::CheckForNeededInsert() st.Bind(1,(now-(1.0/48.0)).Format("%Y-%m-%d %H:%M:%S")); st.Step(); - if(st.RowReturned()) + while(st.RowReturned() && startedinsert==false) { int localidentityid; st.ResultInt(0,localidentityid); - StartInsert(localidentityid); + startedinsert=StartInsert(localidentityid); + st.Step(); } } @@ -121,7 +123,7 @@ void MessageListInserter::Initialize() StringFunctions::Convert(tempval,m_daysbackward); } -void MessageListInserter::StartInsert(const long &localidentityid) +const bool MessageListInserter::StartInsert(const long &localidentityid) { FCPMessage message; DateTime date; @@ -214,16 +216,28 @@ void MessageListInserter::StartInsert(const long &localidentityid) // actually insert message xmlstr=mlxml.GetXML(); - StringFunctions::Convert(xmlstr.size(),xmlsizestr); - message.SetName("ClientPut"); - message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|MessageList|"+indexstr+".xml"; - message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"]; - message["UploadFrom"]="direct"; - message["DataLength"]=xmlsizestr; - m_fcp->SendMessage(message); - m_fcp->SendRaw(xmlstr.c_str(),xmlstr.size()); + // only insert if the last message this identity inserted is different than this message + if(m_lastinsertedxml[localidentityid]!=xmlstr) + { + StringFunctions::Convert(xmlstr.size(),xmlsizestr); + + message.SetName("ClientPut"); + message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|MessageList|"+indexstr+".xml"; + message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"]; + message["UploadFrom"]="direct"; + message["DataLength"]=xmlsizestr; + m_fcp->SendMessage(message); + m_fcp->SendRaw(xmlstr.c_str(),xmlstr.size()); + + m_inserting.push_back(localidentityid); - m_inserting.push_back(localidentityid); + m_lastinsertedxml[localidentityid]=xmlstr; + return true; + } + else + { + return false; + } }