Fix `emerge -s` download size calculation for bug #130750.
authorZac Medico <zmedico@gentoo.org>
Fri, 21 Apr 2006 19:07:30 +0000 (19:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 21 Apr 2006 19:07:30 +0000 (19:07 -0000)
svn path=/main/trunk/; revision=3184

bin/emerge
pym/portage_manifest.py

index 49bc19bbd6fc1043559bb682ffd49f97a8bb873a..09ba5bc0fcf178959eadc94f948eeff418bc1125 100755 (executable)
@@ -784,26 +784,20 @@ class search:
                                        mysum = [0,0]
                                        mycat = match.split("/")[0]
                                        mypkg = match.split("/")[1]
-
-                                       mydigest = portage.db["/"]["porttree"].dbapi.finddigest(mycat+"/"+mypkg + "-" + myversion)
-
-                                       try:
-                                               myfile = open(mydigest,"r")
-                                               for line in myfile.readlines():
-                                                       mysum[0] += int(line.split(" ")[3])
-                                               myfile.close()
-                                               mystr = str(mysum[0]/1024)
-                                               mycount=len(mystr)
-                                               while (mycount > 3):
-                                                       mycount-=3
-                                                       mystr=mystr[:mycount]+","+mystr[mycount:]
-                                               mysum[0]=mystr+" kB"
-                                       except SystemExit, e:
-                                               raise # Needed else can't exit
-                                       except Exception, e:
-                                               if edebug:
-                                                       print "!!! Exception:",e
-                                               mysum[0]=" [no/bad digest]"
+                                       mycpv = match + "-" + myversion
+                                       myebuild = portage.portdb.findname(mycpv)
+                                       pkgdir = os.path.dirname(myebuild)
+                                       import portage_manifest
+                                       mf = portage_manifest.Manifest(pkgdir,
+                                               portage.FetchlistDict(pkgdir, portage.settings),
+                                               portage.settings["DISTDIR"])
+                                       mysum[0] = mf.getDistfilesSize(mf.fetchlist_dict[mycpv])
+                                       mystr = str(mysum[0]/1024)
+                                       mycount=len(mystr)
+                                       while (mycount > 3):
+                                               mycount-=3
+                                               mystr=mystr[:mycount]+","+mystr[mycount:]
+                                       mysum[0]=mystr+" kB"
 
                                        if "--quiet" not in myopts:
                                                print "     ", darkgreen("Latest version available:"),myversion
index 1b7135c97b39741827b0b486a14631b97736a561..06f6ac6edc46be9f2b9468eb5535b5cb58ebdcc2 100644 (file)
@@ -486,7 +486,13 @@ class Manifest(object):
        def _getCpvDistfiles(self, cpv):
                """ Get a list of all DIST files associated to the given cpv """
                return self.fetchlist_dict[cpv]
-       
+
+       def getDistfilesSize(self, fetchlist):
+               total_bytes = 0
+               for f in fetchlist:
+                       total_bytes += int(self.fhashdict["DIST"][f]["size"])
+               return total_bytes
+
        def updateFileHashes(self, ftype, fname, checkExisting=True, ignoreMissing=True, reuseExisting=False):
                """ Regenerate hashes for the given file """
                if checkExisting: