From b6bb14506ccc2eb68917c6b1caa96ba45a445ac5 Mon Sep 17 00:00:00 2001 From: Geoff Jukes Date: Mon, 21 Sep 2020 16:38:31 -0700 Subject: [PATCH] Check path for `hassyspath` and use `shutil.rmdir` if True --- fs/base.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/base.py b/fs/base.py index a6218b93..46a8bcb9 100644 --- a/fs/base.py +++ b/fs/base.py @@ -12,6 +12,7 @@ import hashlib import itertools import os +import shutil import threading import time import typing @@ -1219,17 +1220,20 @@ def removetree(self, dir_path): dir_path (str): Path to a directory on the filesystem. """ - _dir_path = abspath(normpath(dir_path)) with self._lock: - walker = walk.Walker(search="depth") - gen_info = walker.info(self, _dir_path) - for _path, info in gen_info: - if info.is_dir: - self.removedir(_path) - else: - self.remove(_path) - if _dir_path != "/": - self.removedir(dir_path) + if self.hassyspath(path): + shutil.rmtree(self.getsyspath(path)) + else: + _dir_path = abspath(normpath(dir_path)) + walker = walk.Walker(search="depth") + gen_info = walker.info(self, _dir_path) + for _path, info in gen_info: + if info.is_dir: + self.removedir(_path) + else: + self.remove(_path) + if _dir_path != "/": + self.removedir(dir_path) def scandir( self,