plugin XEP-0329: check files conflict also for root files

This commit is contained in:
Goffi 2021-04-16 18:32:40 +02:00
commit 618917e0ef

View file

@ -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(