core (memory): fileDelete is now async, fix coroutine issue

This commit is contained in:
Goffi 2022-05-16 14:37:58 +02:00
commit c8df7104eb

View file

@ -1811,8 +1811,7 @@ class Memory:
raise exceptions.InternalError('Unexpected file type: {file_type}'
.format(file_type=file_data['type']))
@defer.inlineCallbacks
def fileDelete(self, client, peer_jid, file_id, recursive=False):
async def fileDelete(self, client, peer_jid, file_id, recursive=False):
"""Delete a single file or a directory and all its sub-files
@param file_id(unicode): id of the file to delete
@ -1822,7 +1821,7 @@ class Memory:
"""
# FIXME: we only allow owner of file to delete files for now, but WRITE access
# should be checked too
files_data = yield self.getFiles(client, peer_jid, file_id)
files_data = await self.getFiles(client, peer_jid, file_id)
if not files_data:
raise exceptions.NotFound("Can't find the file with id {file_id}".format(
file_id=file_id))
@ -1830,7 +1829,7 @@ class Memory:
if file_data["type"] != C.FILE_TYPE_DIRECTORY and recursive:
raise ValueError("recursive can only be set for directories")
files_path = self.host.getLocalPath(None, C.FILES_DIR, profile=False)
yield self._deleteFile(client, peer_jid, recursive, files_path, file_data)
await self._deleteFile(client, peer_jid, recursive, files_path, file_data)
## Cache ##