diff sat/plugins/plugin_xep_0329.py @ 3500:73b8a8d938be

plugin XEP-0329: check files conflict also for root files
author Goffi <goffi@goffi.org>
date Fri, 16 Apr 2021 18:32:40 +0200
parents be6d91572633
children e47aa1fb7b24
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0329.py	Fri Apr 16 18:32:37 2021 +0200
+++ b/sat/plugins/plugin_xep_0329.py	Fri Apr 16 18:32:40 2021 +0200
@@ -1086,22 +1086,21 @@
             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(