Skip to content

Commit

Permalink
fs: don't call makedirs() if the dirs already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
David Scott committed May 30, 2012
1 parent 5c5d254 commit d661edc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
11 changes: 0 additions & 11 deletions python/util.py
Expand Up @@ -224,14 +224,3 @@ def ismount(path):
if ino1 == ino2:
return True # path/.. is the same i-node as path
return False

def makedirs(name, mode=0777):
head, tail = os.path.split(name)
if not tail:
head, tail = os.path.split(head)
if head and tail and not pathexists(head):
makedirs(head, mode)
if tail == os.curdir:
return
os.mkdir(name, mode)

4 changes: 3 additions & 1 deletion python/xcp.py
Expand Up @@ -109,7 +109,9 @@ def __init__(self, addr, requestHandler=RequestHandler):
self.logRequests = 0
if os.path.exists(addr):
os.unlink(addr)
os.makedirs(os.path.dirname(addr))
dir = os.path.dirname(addr)
if not(os.path.exists(dir)):
os.makedirs(dir)
SimpleXMLRPCDispatcher.__init__(self)
UnixStreamServer.__init__(self, addr, requestHandler)

Expand Down

0 comments on commit d661edc

Please sign in to comment.