Commit 566097df authored by André Anjos's avatar André Anjos 💬
Browse files

Double check directory existence before trying to list it

parent 53629cad
......@@ -36,7 +36,7 @@ def try_remove_files(filename, recurse, verbose):
os.unlink(k)
if verbose: print verbose + ("removed `%s'" % k)
d = os.path.dirname(k)
if recurse and not os.listdir(d):
if recurse and os.path.exists(d) and not os.listdir(d):
os.removedirs(d)
if verbose: print verbose + ("recursively removed `%s'" % d)
......@@ -45,7 +45,7 @@ def try_remove_files(filename, recurse, verbose):
os.unlink(filename)
if verbose: print verbose + ("removed `%s'" % filename)
d = os.path.dirname(filename)
if recurse and not os.listdir(d):
if recurse and os.path.exists(d) and not os.listdir(d):
os.removedirs(d)
if verbose: print verbose + ("recursively removed `%s'" % d)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment