summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind/src/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/glusterfind/src/main.py')
-rw-r--r--tools/glusterfind/src/main.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index 16dc18bd732..850024be2fe 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -9,7 +9,7 @@
# cases as published by the Free Software Foundation.
import sys
-from errno import ENOENT
+from errno import ENOENT, ENOTEMPTY
import time
from multiprocessing import Process
import os
@@ -454,6 +454,15 @@ def mode_delete(session_dir, args):
shutil.rmtree(os.path.join(session_dir, args.volume),
onerror=handle_rm_error)
+ # If the session contains only this volume, then cleanup the
+ # session directory. If a session contains multiple volumes
+ # then os.rmdir will fail with ENOTEMPTY
+ try:
+ os.rmdir(session_dir)
+ except OSError as e:
+ if not e.errno == ENOTEMPTY:
+ logger.warn("Failed to delete session directory: %s" % e)
+
def mode_list(session_dir, args):
"""