changeset 3782:580df5b557be

core (memory): `fileDelete` is now async, fix coroutine issue
author Goffi <goffi@goffi.org>
date Mon, 16 May 2022 14:37:58 +0200
parents e2a1ac1afb38
children fedbf7aade11
files sat/memory/memory.py
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sat/memory/memory.py	Mon May 16 14:20:01 2022 +0200
+++ b/sat/memory/memory.py	Mon May 16 14:37:58 2022 +0200
@@ -1811,8 +1811,7 @@
             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 @@
         """
         # 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 @@
         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 ##