Skip to content

Commit

Permalink
Merge pull request #2 from lck/master
Browse files Browse the repository at this point in the history
optimized unlinking of junctioned dirs on windows
  • Loading branch information
davisagli committed May 12, 2012
2 parents 1d2acfe + d83c158 commit 36fd3c0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions collective/recipe/omelette/utils.py
Expand Up @@ -16,15 +16,19 @@ def symlink(source, link_name):

def unlink(path):
if not ntfsutils.junction.isjunction(path):
return
return False
ntfsutils.junction.unlink(path)
return True

def rmtree(location, nonlinks=True):
# Explicitly unlink all junction'd links
for root, dirs, files in os.walk(location, topdown=False):
for dir in dirs:
path = os.path.join(root, dir)
unlink(path)
names = os.listdir(location)
for dir in names:
path = os.path.join(location, dir)
if unlink(path):
continue
if os.path.isdir(path):
rmtree(path)
# Then get rid of everything else
if nonlinks:
shutil.rmtree(location)
Expand Down

0 comments on commit 36fd3c0

Please sign in to comment.