From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2C6A8138A1C for ; Mon, 6 Apr 2015 04:47:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 47E7BE09AE; Mon, 6 Apr 2015 04:47:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BFB9DE09AB for ; Mon, 6 Apr 2015 04:47:28 +0000 (UTC) Received: from localhost.localdomain (ip174-67-205-96.oc.oc.cox.net [174.67.205.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 260FE340B08; Mon, 6 Apr 2015 04:47:27 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= , Zac Medico Subject: [gentoo-portage-dev] [PATCH v2] fetch(): fix support for digest size=None Date: Sun, 5 Apr 2015 21:47:12 -0700 Message-Id: <1428295632-21092-1-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.3.1 In-Reply-To: <1428220769-3567-1-git-send-email-mgorny@gentoo.org> References: <1428220769-3567-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 21f98c7d-5006-4295-9ecf-607918c1390f X-Archives-Hash: 08ff3cb07e52c97225634f956dbcd49a From: Michał Górny It seems that the code initially supported fetching without size 'digest' but it got broken over time. Add proper conditionals to avoid ugly failures in this case. Signed-off-by: Zac Medico --- [PATCH v2] uses dict.get() so that the "size" key is not required https://github.com/zmedico/portage/tree/mgorny-fetch-size-missing pym/portage/checksum.py | 2 +- pym/portage/package/ebuild/fetch.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index f24a90f..642602e 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -303,7 +303,7 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0): reason = "Reason unknown" try: mysize = os.stat(filename)[stat.ST_SIZE] - if mydict["size"] != mysize: + if mydict.get("size") is not None and mydict["size"] != mysize: return False,(_("Filesize does not match recorded size"), mysize, mydict["size"]) except OSError as e: if e.errno == errno.ENOENT: diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 7b856a2..7e4e6fe 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -700,7 +700,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, os.unlink(myfile_path) except OSError: pass - elif distdir_writable: + elif distdir_writable and size is not None: if mystat.st_size < fetch_resume_size and \ mystat.st_size < size: # If the file already exists and the size does not @@ -806,8 +806,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, # assume that it is fully downloaded. continue else: - if mystat.st_size < mydigests[myfile]["size"] and \ - not restrict_fetch: + if (mydigests[myfile].get("size") is not None + and mystat.st_size < mydigests[myfile]["size"] + and not restrict_fetch): fetched = 1 # Try to resume this download. elif parallel_fetchonly and \ mystat.st_size == mydigests[myfile]["size"]: -- 2.3.1