]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_cephfs.py: delete purge_dir() helper method, use rmtree() instead 64774/head
authorRishabh Dave <ridave@redhat.com>
Mon, 6 Apr 2026 06:39:12 +0000 (12:09 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 16 Apr 2026 12:41:08 +0000 (18:11 +0530)
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 <ridave@redhat.com>
src/test/pybind/test_cephfs.py

index d9fc9aed71ff08e366601e10e4b6e52ab85f7d13..89db36fa8a7383ada80fc4836073801bf04c38f7 100644 (file)
@@ -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("/")