core (memory, sqlite): added fileUpdate method to update "extra" and "access" avoiding race condition

This commit is contained in:
Goffi 2018-03-16 17:03:46 +01:00
commit 97f19b2e52

View file

@ -1302,6 +1302,18 @@ class Memory(object):
owner=owner,
access=access, extra=extra)
def fileUpdate(self, file_id, column, update_cb):
"""update a file column taking care of race condition
access is NOT checked in this method, it must be checked beforehand
@param file_id(unicode): id of the file to update
@param column(unicode): one of "access" or "extra"
@param update_cb(callable): method to update the value of the colum
the method will take older value as argument, and must update it in place
Note that the callable must be thread-safe
"""
return self.storage.fileUpdate(file_id, column, update_cb)
## Misc ##
def isEntityAvailable(self, entity_jid, profile_key):