summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-04-21 22:34:41 +0000
committerZac Medico <zmedico@gentoo.org>2006-04-21 22:34:41 +0000
commitdb24ca53e8b77dace12ea5826825db599c5604f3 (patch)
tree38dc28df00bfb6ae3fa9a50651f6ecbc8ab0dc2f
parent5f713b628b4445b8c0e18e08e762b1ef301fdab1 (diff)
downloadportage-db24ca53e8b77dace12ea5826825db599c5604f3.tar.gz
portage-db24ca53e8b77dace12ea5826825db599c5604f3.tar.bz2
portage-db24ca53e8b77dace12ea5826825db599c5604f3.zip
Fix partial download size calculation for bug #116796.
svn path=/main/trunk/; revision=3185
-rw-r--r--pym/portage.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 13495c3dc..e0e178c81 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -4802,12 +4802,27 @@ class portdbapi(dbapi):
#XXX: maybe this should be improved: take partial downloads
# into account? check checksums?
for myfile in myfiles:
- if debug and myfile not in checksums.keys():
- print "[bad digest]: missing",myfile,"for",mypkg
- elif myfile in checksums.keys():
- distfile=settings["DISTDIR"]+"/"+myfile
- if not os.access(distfile, os.R_OK):
- filesdict[myfile]=int(checksums[myfile]["size"])
+ if myfile not in checksums:
+ if debug:
+ writemsg("[bad digest]: missing %s for %s\n" % (myfile, mypkg))
+ continue
+ file_path = os.path.join(self.mysettings["DISTDIR"], myfile)
+ mystat = None
+ try:
+ mystat = os.stat(file_path)
+ except OSError, e:
+ pass
+ if mystat is None:
+ existing_size = 0
+ else:
+ existing_size = mystat.st_size
+ remaining_size = int(checksums[myfile]["size"]) - existing_size
+ if remaining_size > 0:
+ # Assume the download is resumable.
+ filesdict[myfile] = remaining_size
+ elif remaining_size < 0:
+ # The existing file is too large and therefore corrupt.
+ filesdict[myfile] = int(checksums[myfile]["size"])
return filesdict
def fetch_check(self, mypkg, useflags=None, mysettings=None, all=False):