From c8df7104ebc62153f7b0e308ef6e54f2fd8c0f50 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 16 May 2022 14:37:58 +0200 Subject: [PATCH] core (memory): `fileDelete` is now async, fix coroutine issue --- sat/memory/memory.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sat/memory/memory.py b/sat/memory/memory.py index 9bc09195..478459f5 100644 --- a/sat/memory/memory.py +++ b/sat/memory/memory.py @@ -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 ##