summaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorJason Stubbs <jstubbs@gentoo.org>2005-12-25 08:39:22 +0000
committerJason Stubbs <jstubbs@gentoo.org>2005-12-25 08:39:22 +0000
commit1e1c18b4d3b000d4ba2e49606c5f65480b9d5ca4 (patch)
tree27312dc3b93e7fecfacc5ce29fca71a40799d211 /pym
parent- remove intermediate var entry (diff)
downloadportage-multirepo-1e1c18b4d3b000d4ba2e49606c5f65480b9d5ca4.tar.gz
portage-multirepo-1e1c18b4d3b000d4ba2e49606c5f65480b9d5ca4.tar.bz2
portage-multirepo-1e1c18b4d3b000d4ba2e49606c5f65480b9d5ca4.zip
Only do one round of directory removal attempts. As symlinks are now removed
before directory removal begins, more than one round is unnecessary. svn path=/main/trunk/; revision=2457
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py51
1 files changed, 15 insertions, 36 deletions
diff --git a/pym/portage.py b/pym/portage.py
index ab665ce6..85490195 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -5739,44 +5739,23 @@ class dblink:
elif pkgfiles[obj][0]=="dev":
print "--- ","dev",obj
- #progress -- are we making progress? Initialized to 1 so loop will start
- progress=1
- while progress:
- #let's see if we're able to make progress this iteration...
- progress=0
-
- pos = 0
- while pos<len(mydirs):
- obj=mydirs[pos]
- objld=listdir(obj)
-
- if objld == None:
- print "mydirs["+str(pos)+"]",mydirs[pos]
- print "obj",obj
- print "objld",objld
- # the directory doesn't exist yet, continue
- pos += 1
- continue
+ mydirs.sort()
+ mydirs.reverse()
+ last_non_empty = ""
- if len(objld)>0:
- #we won't remove this directory (yet), continue
- pos += 1
- continue
- elif (objld != None):
- #zappo time
- del mydirs[pos]
- #we've made progress!
- progress = 1
- try:
- os.rmdir(obj)
- print "<<< ","dir",obj
- except (OSError,IOError),e:
- #immutable?
- pass
+ for obj in mydirs:
+ if not last_non_empty.startswith(obj) and not listdir(obj):
+ try:
+ os.rmdir(obj)
+ print "<<< ","dir",obj
+ last_non_empty = ""
+ except (OSError,IOError),e:
+ #immutable?
+ pass
- #directories that aren't empty:
- for x in mydirs:
- print "--- !empty dir", x
+ print "--- !empty dir", obj
+ last_non_empty = obj
+ continue
#remove self from vartree database so that our own virtual gets zapped if we're the last node
db[self.myroot]["vartree"].zap(self.mycpv)