From 37a03b74e830e3ad18cbcab776121cdcf57ee8b8 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 16 Oct 2008 22:55:46 +0000 Subject: Bug #242304 - When a zero-byte distfile is detected inside fetch(), discard the digests and attempt to fetch the file if possible. This code is triggered via digestgen() when appropriate, so it fixes all digestgen() callers, including repoman. svn path=/main/trunk/; revision=11695 --- pym/portage/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'pym') diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index e03753196..29251ddcd 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3319,6 +3319,9 @@ def _check_distfile(filename, digests, eout, show_errors=1): if size is not None: eout.ebegin("%s %s ;-)" % (os.path.basename(filename), "size")) eout.eend(0) + elif st.st_size == 0: + # Zero-byte distfiles are always invalid. + return (False, st) else: if _check_digests(filename, digests, show_errors=show_errors): eout.ebegin("%s %s ;-)" % (os.path.basename(filename), @@ -3636,6 +3639,10 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", orig_digests = mydigests.get(myfile, {}) size = orig_digests.get("size") + if size == 0: + # Zero-byte distfiles are always invalid, so discard their digests. + orig_digests.clear() + size = None pruned_digests = orig_digests if parallel_fetchonly: pruned_digests = {} @@ -3650,7 +3657,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: # check if there is enough space in DISTDIR to completely store myfile # overestimate the filesize so we aren't bitten by FS overhead - if hasattr(os, "statvfs"): + if size is not None and hasattr(os, "statvfs"): vfs_stat = os.statvfs(mysettings["DISTDIR"]) try: mysize = os.stat(myfile_path).st_size @@ -3659,8 +3666,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", raise del e mysize = 0 - if myfile in mydigests \ - and (mydigests[myfile]["size"] - mysize + vfs_stat.f_bsize) >= \ + if (size - mysize + vfs_stat.f_bsize) >= \ (vfs_stat.f_bsize * vfs_stat.f_bavail): writemsg("!!! Insufficient space to store %s in %s\n" % (myfile, mysettings["DISTDIR"]), noiselevel=-1) has_space = False -- cgit v1.2.3-1-g7c22