core (memory): raise PermissionError directly instead of using failureFailure, as it could not be catched correctly in every case.

This commit is contained in:
Goffi 2019-04-28 08:55:13 +02:00
commit cad0d4b0e2

View file

@ -1233,18 +1233,18 @@ class Memory(object):
perm_data = file_data[u"access"][perm] perm_data = file_data[u"access"][perm]
perm_type = perm_data[u"type"] perm_type = perm_data[u"type"]
except KeyError: except KeyError:
raise failure.Failure(exceptions.PermissionError()) raise exceptions.PermissionError()
if perm_type == C.ACCESS_TYPE_PUBLIC: if perm_type == C.ACCESS_TYPE_PUBLIC:
continue continue
elif perm_type == C.ACCESS_TYPE_WHITELIST: elif perm_type == C.ACCESS_TYPE_WHITELIST:
try: try:
jids = perm_data[u"jids"] jids = perm_data[u"jids"]
except KeyError: except KeyError:
raise failure.Failure(exceptions.PermissionError()) raise exceptions.PermissionError()
if peer_jid.full() in jids: if peer_jid.full() in jids:
continue continue
else: else:
raise failure.Failure(exceptions.PermissionError()) raise exceptions.PermissionError()
else: else:
raise exceptions.InternalError( raise exceptions.InternalError(
_(u"unknown access type: {type}").format(type=perm_type) _(u"unknown access type: {type}").format(type=perm_type)
@ -1530,7 +1530,7 @@ class Memory(object):
) )
def fileUpdate(self, file_id, column, update_cb): def fileUpdate(self, file_id, column, update_cb):
"""update a file column taking care of race condition """Update a file column taking care of race condition
access is NOT checked in this method, it must be checked beforehand access is NOT checked in this method, it must be checked beforehand
@param file_id(unicode): id of the file to update @param file_id(unicode): id of the file to update