comparison src/memory/disco.py @ 2407:cf9b276f4a08

core (disco): do not cache disco items when node is set
author Goffi <goffi@goffi.org>
date Tue, 31 Oct 2017 23:11:58 +0100
parents f047d5410040
children 8b37a62336c3
comparison
equal deleted inserted replaced
2406:1e5b2c35964e 2407:cf9b276f4a08
196 @param jid_(jid.JID): jid of the target, or None for profile's server 196 @param jid_(jid.JID): jid of the target, or None for profile's server
197 @param node(unicode): optional node to use for disco request 197 @param node(unicode): optional node to use for disco request
198 @param use_cache(bool): if True, use cached data if available 198 @param use_cache(bool): if True, use cached data if available
199 @return: a Deferred which fire disco.DiscoItems 199 @return: a Deferred which fire disco.DiscoItems
200 """ 200 """
201 server_jid = jid.JID(client.jid.host)
201 if jid_ is None: 202 if jid_ is None:
202 jid_ = jid.JID(client.jid.host) 203 jid_ = server_jid
203 # we cache items only for our own server 204
205 if jid_ == server_jid and not node:
206 # we cache items only for our own server and if node is not set
204 try: 207 try:
205 items = self.host.memory.getEntityData(jid_, ["DISCO_ITEMS"], client.profile)["DISCO_ITEMS"] 208 items = self.host.memory.getEntityData(jid_, ["DISCO_ITEMS"], client.profile)["DISCO_ITEMS"]
206 log.debug(u"[%s] disco items are in cache" % jid_.full()) 209 log.debug(u"[%s] disco items are in cache" % jid_.full())
207 if not use_cache: 210 if not use_cache:
208 # we ignore cache, so we pretend we haven't found it 211 # we ignore cache, so we pretend we haven't found it