comparison sat/memory/sqlite.py @ 3523:30779935c0aa

core (memory, sqlite): new `fileGetUsedSpace` method
author Goffi <goffi@goffi.org>
date Wed, 05 May 2021 15:37:21 +0200
parents be6d91572633
children 67aebefb44fc
comparison
equal deleted inserted replaced
3522:41a6c144dc90 3523:30779935c0aa
984 json.dumps(extra) if extra else None, 984 json.dumps(extra) if extra else None,
985 self.profiles[client.profile])) 985 self.profiles[client.profile]))
986 d.addErrback(lambda failure: log.error(_("Can't save file metadata for [{profile}]: {reason}".format(profile=client.profile, reason=failure)))) 986 d.addErrback(lambda failure: log.error(_("Can't save file metadata for [{profile}]: {reason}".format(profile=client.profile, reason=failure))))
987 return d 987 return d
988 988
989 async def fileGetUsedSpace(self, client, owner):
990 """Get space used by owner of file"""
991 query = "SELECT SUM(size) FROM files WHERE owner=? AND type='file' AND profile_id=?"
992 ret = await self.dbpool.runQuery(
993 query,
994 (owner.userhost(), self.profiles[client.profile])
995 )
996 return ret[0][0]
997
989 def _fileUpdate(self, cursor, file_id, column, update_cb): 998 def _fileUpdate(self, cursor, file_id, column, update_cb):
990 query = 'SELECT {column} FROM files where id=?'.format(column=column) 999 query = 'SELECT {column} FROM files where id=?'.format(column=column)
991 for i in range(5): 1000 for i in range(5):
992 cursor.execute(query, [file_id]) 1001 cursor.execute(query, [file_id])
993 try: 1002 try: