From f2a0e302dc23233c3f08ad14c89442de0c2a479b Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Mon, 6 Apr 2026 12:09:12 +0530 Subject: [PATCH] test_cephfs.py: delete purge_dir() helper method, use rmtree() instead Use rmtree() instead of purge_dir() for following 2 reasons - 1. purge_dir()'s recursive nature makes it vulnerable to max recursion limit. 2. It is redundant to have purge_dir() helper method since rmtree() already performs job in a better way. Signed-off-by: Rishabh Dave --- src/test/pybind/test_cephfs.py | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index d9fc9aed71ff..89db36fa8a73 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -38,36 +38,10 @@ def teardown_module(): global cephfs cephfs.shutdown() -def purge_dir(path, is_snap = False): - print(b"Purge " + path) - d = cephfs.opendir(path) - if (not path.endswith(b"/")): - path = path + b"/" - dent = cephfs.readdir(d) - while dent: - if (dent.d_name not in [b".", b".."]): - print(path + dent.d_name) - if dent.is_dir(): - if (not is_snap): - try: - snappath = path + dent.d_name + b"/.snap" - cephfs.stat(snappath) - purge_dir(snappath, True) - except: - pass - purge_dir(path + dent.d_name, False) - cephfs.rmdir(path + dent.d_name) - else: - print("rmsnap on {} snap {}".format(path, dent.d_name)) - cephfs.rmsnap(path, dent.d_name); - else: - cephfs.unlink(path + dent.d_name) - dent = cephfs.readdir(d) - cephfs.closedir(d) - @pytest.fixture def testdir(): - purge_dir(b"/") + print(f'purging entire file hierarchy under "/"...') + cephfs.rmtree(b'/') cephfs.chdir(b"/") _, ret_buf = cephfs.listxattr("/") -- 2.47.3