mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05: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_STATUS, (int32_t)grpMetaPtr->mGroupStatus);
|
||||||
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
|
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
|
||||||
|
|
||||||
|
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
|
||||||
|
|
||||||
if (!mDb->sqlInsert(GRP_TABLE_NAME, "", cv))
|
if (!mDb->sqlInsert(GRP_TABLE_NAME, "", cv))
|
||||||
{
|
{
|
||||||
std::cerr << "RsDataService::storeGroup() sqlInsert Failed";
|
std::cerr << "RsDataService::storeGroup() sqlInsert Failed";
|
||||||
@ -906,6 +908,12 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||||||
return ret;
|
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)
|
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);
|
cv.put(KEY_GRP_LAST_POST, (int32_t)grpMetaPtr->mLastPost);
|
||||||
|
|
||||||
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
|
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
|
||||||
|
|
||||||
|
locked_clearGrpMetaCache(grpMetaPtr->mGroupId);
|
||||||
}
|
}
|
||||||
// finish transaction
|
// finish transaction
|
||||||
bool ret = mDb->commitTransaction();
|
bool ret = mDb->commitTransaction();
|
||||||
@ -1453,8 +1463,7 @@ int RsDataService::updateGroupMetaData(GrpLocMetaData &meta)
|
|||||||
std::cerr << (void*)this << ": erasing old entry from cache." << std::endl;
|
std::cerr << (void*)this << ": erasing old entry from cache." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mGrpMetaDataCache_ContainsAllDatabase = false ;
|
locked_clearGrpMetaCache(meta.grpId);
|
||||||
mGrpMetaDataCache.erase(meta.grpId) ;
|
|
||||||
|
|
||||||
return mDb->sqlUpdate(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", meta.val) ? 1 : 0;
|
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 boolean variable below is also used to force re-reading when
|
||||||
// the entre list of grp metadata is requested (which happens quite often)
|
// the entre list of grp metadata is requested (which happens quite often)
|
||||||
|
|
||||||
|
void locked_clearGrpMetaCache(const RsGxsGroupId& gid);
|
||||||
|
|
||||||
std::map<RsGxsGroupId,RsGxsGrpMetaData> mGrpMetaDataCache ;
|
std::map<RsGxsGroupId,RsGxsGrpMetaData> mGrpMetaDataCache ;
|
||||||
bool mGrpMetaDataCache_ContainsAllDatabase ;
|
bool mGrpMetaDataCache_ContainsAllDatabase ;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user