From 618917e0efacbfc8bbcaf5b17fdbd29131c05e3a Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 16 Apr 2021 18:32:40 +0200 Subject: [PATCH] plugin XEP-0329: check files conflict also for root files --- sat/plugins/plugin_xep_0329.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/sat/plugins/plugin_xep_0329.py b/sat/plugins/plugin_xep_0329.py index c0689071..e27e6b80 100644 --- a/sat/plugins/plugin_xep_0329.py +++ b/sat/plugins/plugin_xep_0329.py @@ -1086,22 +1086,21 @@ class XEP_0329(object): client.sendError(iq_elt, 'forbidden', "You can't create a directory there") return # when going further into the path, the permissions will be checked by getFiles - if len(path.parts) > 2: - files_data = await self.host.memory.getFiles( - client, - peer_jid=peer_jid, - path=path.parent, - namespace=namespace, - owner=owner, + files_data = await self.host.memory.getFiles( + client, + peer_jid=peer_jid, + path=path.parent, + namespace=namespace, + owner=owner, + ) + if path.name in [d['name'] for d in files_data]: + log.warning( + f"Conflict when trying to create a directory (from: {peer_jid} " + f"namespace: {namespace!r} path: {path!r})" ) - if path.name in [d['name'] for d in files_data]: - log.warning( - f"Conflict when trying to create a directory (from: {peer_jid} " - f"namespace: {namespace!r} path: {path!r})" - ) - client.sendError( - iq_elt, 'conflict', "there is already a file or dir at this path") - return + client.sendError( + iq_elt, 'conflict', "there is already a file or dir at this path") + return try: configuration_elt = next(