core (memory, sqlite): new fileGetUsedSpace method

This commit is contained in:
Goffi 2021-05-05 15:37:21 +02:00
commit 06054ceeaf

View file

@ -986,6 +986,15 @@ class SqliteStorage(object):
d.addErrback(lambda failure: log.error(_("Can't save file metadata for [{profile}]: {reason}".format(profile=client.profile, reason=failure))))
return d
async def fileGetUsedSpace(self, client, owner):
"""Get space used by owner of file"""
query = "SELECT SUM(size) FROM files WHERE owner=? AND type='file' AND profile_id=?"
ret = await self.dbpool.runQuery(
query,
(owner.userhost(), self.profiles[client.profile])
)
return ret[0][0]
def _fileUpdate(self, cursor, file_id, column, update_cb):
query = 'SELECT {column} FROM files where id=?'.format(column=column)
for i in range(5):