comparison src/memory/memory.py @ 2526:35d591086974

core (memory, sqlite): added fileUpdate method to update "extra" and "access" avoiding race condition
author Goffi <goffi@goffi.org>
date Fri, 16 Mar 2018 17:03:46 +0100
parents e4de2f16a284
children 8d82a62fa098
comparison
equal deleted inserted replaced
2525:e8e1507049b7 2526:35d591086974
1300 file_hash=file_hash, hash_algo=hash_algo, name=name, size=size, 1300 file_hash=file_hash, hash_algo=hash_algo, name=name, size=size,
1301 namespace=namespace, mime_type=mime_type, created=created, modified=modified, 1301 namespace=namespace, mime_type=mime_type, created=created, modified=modified,
1302 owner=owner, 1302 owner=owner,
1303 access=access, extra=extra) 1303 access=access, extra=extra)
1304 1304
1305 def fileUpdate(self, file_id, column, update_cb):
1306 """update a file column taking care of race condition
1307
1308 access is NOT checked in this method, it must be checked beforehand
1309 @param file_id(unicode): id of the file to update
1310 @param column(unicode): one of "access" or "extra"
1311 @param update_cb(callable): method to update the value of the colum
1312 the method will take older value as argument, and must update it in place
1313 Note that the callable must be thread-safe
1314 """
1315 return self.storage.fileUpdate(file_id, column, update_cb)
1316
1305 ## Misc ## 1317 ## Misc ##
1306 1318
1307 def isEntityAvailable(self, entity_jid, profile_key): 1319 def isEntityAvailable(self, entity_jid, profile_key):
1308 """Tell from the presence information if the given entity is available. 1320 """Tell from the presence information if the given entity is available.
1309 1321