From 607b1607e060ea27a693e7922af58a26ba51d1a0 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 3 Dec 2004 19:44:47 +0000 Subject: fix mkdir -p case (Logical change 1.157) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@699 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Toolset.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py index 390c560bd..ec41620b7 100644 --- a/src/lib/Client/Toolset.py +++ b/src/lib/Client/Toolset.py @@ -271,17 +271,18 @@ class Toolset(object): return False parent = "/".join(entry.get('name').split('/')[:-1]) if parent: - try: - sloc = lstat(parent) + for idx in xrange(len(parent.split('/')[:-1])): + current = '/'+'/'.join(parent.split('/')[1:2+idx]) try: - if not S_ISDIR(sloc[ST_MODE]): - unlink(parent) - mkdir(parent) + sloc = lstat(current) + try: + if not S_ISDIR(sloc[ST_MODE]): + unlink(current) + mkdir(current) + except OSError: + return False except OSError: - return False - except OSError: - # need to handle mkdir -p case - mkdir(parent) + mkdir(current) # If we get here, then the parent directory should exist try: -- cgit v1.2.3-1-g7c22