mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed missing RsGxsGrpMeta cache update when updating grp meta, which caused unstable group flags/name/perms update
This commit is contained in:
parent
95edc5ba8e
commit
daf54dff3d
@ -883,6 +883,8 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
cv.put(KEY_GRP_STATUS, (int32_t)grpMetaPtr->mGroupStatus);
|
||||
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
|
||||
|
||||
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
|
||||
|
||||
if (!mDb->sqlInsert(GRP_TABLE_NAME, "", cv))
|
||||
{
|
||||
std::cerr << "RsDataService::storeGroup() sqlInsert Failed";
|
||||
@ -906,6 +908,12 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid)
|
||||
{
|
||||
mGrpMetaDataCache.erase(gid) ; // cleans existing cache entry
|
||||
mGrpMetaDataCache_ContainsAllDatabase = false;
|
||||
}
|
||||
|
||||
int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
{
|
||||
|
||||
@ -973,6 +981,8 @@ int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
|
||||
|
||||
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
|
||||
|
||||
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
|
||||
}
|
||||
// finish transaction
|
||||
bool ret = mDb->commitTransaction();
|
||||
@ -1453,8 +1463,7 @@ int RsDataService::updateGroupMetaData(GrpLocMetaData &meta)
|
||||
std::cerr << (void*)this << ": erasing old entry from cache." << std::endl;
|
||||
#endif
|
||||
|
||||
mGrpMetaDataCache_ContainsAllDatabase = false ;
|
||||
mGrpMetaDataCache.erase(meta.grpId) ;
|
||||
locked_clearGrpMetaCache(meta.grpId);
|
||||
|
||||
return mDb->sqlUpdate(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", meta.val) ? 1 : 0;
|
||||
}
|
||||
|
@ -345,6 +345,8 @@ private:
|
||||
// The boolean variable below is also used to force re-reading when
|
||||
// the entre list of grp metadata is requested (which happens quite often)
|
||||
|
||||
void locked_clearGrpMetaCache(const RsGxsGroupId& gid);
|
||||
|
||||
std::map<RsGxsGroupId,RsGxsGrpMetaData> mGrpMetaDataCache ;
|
||||
bool mGrpMetaDataCache_ContainsAllDatabase ;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user