X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fidentityinserter.cpp;h=3fabf007174a222a5d87b832c247debd0c08212c;hb=c7fcb4c4bc5012a584add81a9509fc1f84c3c688;hp=571546a7c5d3b1c1fabd5d47bf4becd9d0a71ad8;hpb=8adfd604a97d385869b0ce763b35d014d7aa2cca;p=fms.git diff --git a/src/freenet/identityinserter.cpp b/src/freenet/identityinserter.cpp index 571546a..3fabf00 100644 --- a/src/freenet/identityinserter.cpp +++ b/src/freenet/identityinserter.cpp @@ -80,7 +80,18 @@ const bool IdentityInserter::HandleMessage(FCPMessage &message) if(message.GetName()=="PutSuccessful") { - m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false', LastInsertedIdentity='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";"); + // a little hack here - if we just inserted index yesterday and it is now the next day - we would have inserted todays date not yesterdays as LastInsertedIdentity. + // If this is the case, we will skip updating LastInsertedIdentity so that we can insert this identity again for today + DateTime lastdate; + lastdate.Set(idparts[4]); + if(lastdate.GetDay()==now.GetDay()) + { + m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false', LastInsertedIdentity='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";"); + } + else + { + m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false' WHERE LocalIdentityID="+idparts[1]+";"); + } m_db->Execute("INSERT INTO tblLocalIdentityInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");"); m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityInserter::HandleMessage inserted Identity xml"); return true; @@ -172,7 +183,7 @@ void IdentityInserter::StartInsert(const long localidentityid) } StringFunctions::Convert(index,indexstr); - Option::instance()->Get("MessageBase",messagebase); + Option::Instance()->Get("MessageBase",messagebase); if(rs.GetField(0)) {