comparison sat/memory/memory.py @ 2926:4cd7545c4ebb

core (memory): raise PermissionError directly instead of using failureFailure, as it could not be catched correctly in every case.
author Goffi <goffi@goffi.org>
date Sun, 28 Apr 2019 08:55:13 +0200
parents 59aea54e74a8
children c0f6fd75af5f
comparison
equal deleted inserted replaced
2925:03a09e16bf28 2926:4cd7545c4ebb
1231 # we must never return here, we only return after the loop if nothing was blocking the access 1231 # we must never return here, we only return after the loop if nothing was blocking the access
1232 try: 1232 try:
1233 perm_data = file_data[u"access"][perm] 1233 perm_data = file_data[u"access"][perm]
1234 perm_type = perm_data[u"type"] 1234 perm_type = perm_data[u"type"]
1235 except KeyError: 1235 except KeyError:
1236 raise failure.Failure(exceptions.PermissionError()) 1236 raise exceptions.PermissionError()
1237 if perm_type == C.ACCESS_TYPE_PUBLIC: 1237 if perm_type == C.ACCESS_TYPE_PUBLIC:
1238 continue 1238 continue
1239 elif perm_type == C.ACCESS_TYPE_WHITELIST: 1239 elif perm_type == C.ACCESS_TYPE_WHITELIST:
1240 try: 1240 try:
1241 jids = perm_data[u"jids"] 1241 jids = perm_data[u"jids"]
1242 except KeyError: 1242 except KeyError:
1243 raise failure.Failure(exceptions.PermissionError()) 1243 raise exceptions.PermissionError()
1244 if peer_jid.full() in jids: 1244 if peer_jid.full() in jids:
1245 continue 1245 continue
1246 else: 1246 else:
1247 raise failure.Failure(exceptions.PermissionError()) 1247 raise exceptions.PermissionError()
1248 else: 1248 else:
1249 raise exceptions.InternalError( 1249 raise exceptions.InternalError(
1250 _(u"unknown access type: {type}").format(type=perm_type) 1250 _(u"unknown access type: {type}").format(type=perm_type)
1251 ) 1251 )
1252 1252
1528 access=access, 1528 access=access,
1529 extra=extra, 1529 extra=extra,
1530 ) 1530 )
1531 1531
1532 def fileUpdate(self, file_id, column, update_cb): 1532 def fileUpdate(self, file_id, column, update_cb):
1533 """update a file column taking care of race condition 1533 """Update a file column taking care of race condition
1534 1534
1535 access is NOT checked in this method, it must be checked beforehand 1535 access is NOT checked in this method, it must be checked beforehand
1536 @param file_id(unicode): id of the file to update 1536 @param file_id(unicode): id of the file to update
1537 @param column(unicode): one of "access" or "extra" 1537 @param column(unicode): one of "access" or "extra"
1538 @param update_cb(callable): method to update the value of the colum 1538 @param update_cb(callable): method to update the value of the colum