summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-11-06 22:08:00 +0100
committerJeremy Allison <jra@samba.org>2020-11-16 19:53:44 +0000
commit13aecb22f75f24d47a3163c701018f67e30a1a2c (patch)
treeed912a427277a43184ddd2a569067dce2b609206 /python
parent2cff5990daa324226a2c32245eef78019ef1b5bf (diff)
downloadsamba-13aecb22f75f24d47a3163c701018f67e30a1a2c.tar.gz
pylibsmb: Move deltree to python code
This is much shorter. There's also another aspect: I'm working on improving cli_list() to not collect all files before starting to call the callback function. This means that the cli_list cb will be called from within tevent_loop_once(). In pylibsmb.c's deltree code this would create a nested event loop. By moving the deltree code into the python world this nested event loop is avoided. Now the python code will first collect everything and then start to delete, avoiding the nesting. A future development should make listing directories a generator or something like that. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/samba3/libsmb_samba_internal.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/python/samba/samba3/libsmb_samba_internal.py b/python/samba/samba3/libsmb_samba_internal.py
index d8621a270a6..d0d611fbc5d 100644
--- a/python/samba/samba3/libsmb_samba_internal.py
+++ b/python/samba/samba3/libsmb_samba_internal.py
@@ -16,4 +16,10 @@
from samba.samba3.libsmb_samba_cwrapper import *
class Conn(LibsmbCConn):
- pass
+ def deltree(self, path):
+ if self.chkpath(path):
+ for entry in self.list(path):
+ self.deltree(path + "\\" + entry['name'])
+ self.rmdir(path)
+ else:
+ self.unlink(path)