X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fidentityinserter.cpp;h=aa1f4ab8f19ecb8ebb6e9fa28f3cf0b0cfc3a224;hb=964f55fd550fc711c0320ce6a24ad713040695d0;hp=028f49568f30b1c75b74c76d3a99b2a8bff42cde;hpb=1b0c3b7f86935a772aad271bad4f3d1f37243c2d;p=fms.git diff --git a/src/freenet/identityinserter.cpp b/src/freenet/identityinserter.cpp index 028f495..aa1f4ab 100644 --- a/src/freenet/identityinserter.cpp +++ b/src/freenet/identityinserter.cpp @@ -26,10 +26,13 @@ void IdentityInserter::CheckForNeededInsert() // set date to 1 hour back date.Add(0,0,-1); - // Because of importance of Identity.xml, if we are now at the next day we immediately want to insert identities so change the date back to now + // Because of importance of Identity.xml, if we are now at the next day we immediately want to insert identities so change the date back to 12:00 AM so we find all identities not inserted yet today if(date.GetDay()!=now.GetDay()) { date=now; + date.SetHour(0); + date.SetMinute(0); + date.SetSecond(0); } SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE PrivateKey IS NOT NULL AND PrivateKey <> '' AND InsertingIdentity='false' AND (LastInsertedIdentity<'"+date.Format("%Y-%m-%d %H:%M:%S")+"' OR LastInsertedIdentity IS NULL) ORDER BY LastInsertedIdentity;"); @@ -77,16 +80,23 @@ 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]+";"); + } m_db->Execute("INSERT INTO tblLocalIdentityInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" inserted identity xml"); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityInserter::HandleMessage inserted Identity xml"); return true; } if(message.GetName()=="PutFailed") { m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false' WHERE LocalIdentityID="+idparts[1]+";"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" failure inserting identity xml. Code="+message["Code"]+" Description="+message["CodeDescription"]); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityInserter::HandleMessage failure inserting Identity xml. Code="+message["Code"]+" Description="+message["CodeDescription"]); // if code 9 (collision), then insert index into inserted table if(message["Code"]=="9") @@ -195,7 +205,7 @@ void IdentityInserter::StartInsert(const long localidentityid) if(rs.GetField(4)) { - publishboardlist=rs.GetField(3); + publishboardlist=rs.GetField(4); } publishboardlist=="true" ? idxml.SetPublishBoardList(true) : idxml.SetPublishBoardList(false);