INNER CODE UNIT · Python
safe_remove_tree
Silverlan/pragma · build_scripts/build_third_party_libs.py:26
def safe_remove_tree(path, retries=5, delay=0.5):
p = Path(path)
if not p.exists():
return True
# .git dir is often problematic because it may still be in use by the system, so we'll try to delete it first
git_dir = p / '.git'
if git_dir.exists():
try:
shutil.rmtree(git_dir, onerror=on_rm_error)
except Exception:
pass
# Move the tree to temp trash
trash_parent = Path(tempfile.gettempdir())
trash_name = "build-trash-" + uuid.uuid4().hex
trash_path = trash_parent / trash_name