Only do one round of directory removal attempts. As symlinks are now removed
authorJason Stubbs <jstubbs@gentoo.org>
Sun, 25 Dec 2005 08:39:22 +0000 (08:39 -0000)
committerJason Stubbs <jstubbs@gentoo.org>
Sun, 25 Dec 2005 08:39:22 +0000 (08:39 -0000)
before directory removal begins, more than one round is unnecessary.

svn path=/main/trunk/; revision=2457

pym/portage.py

index ab665ce641e1420405c08eeab10821559b1f4817..854901956dc3fc5e675015faeb35591e8f60f1eb 100644 (file)
@@ -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)