public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] fetch(): fix support for digest size=None
Date: Sun,  5 Apr 2015 09:59:29 +0200	[thread overview]
Message-ID: <1428220769-3567-1-git-send-email-mgorny@gentoo.org> (raw)

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.
---
 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..1efe74e 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["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..f60db9e 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]["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.5



             reply	other threads:[~2015-04-05  7:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-05  7:59 Michał Górny [this message]
2015-04-05 17:57 ` [gentoo-portage-dev] [PATCH] fetch(): fix support for digest size=None Zac Medico
2015-04-05 21:55   ` Michał Górny
2015-04-06  4:47 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
2015-04-06  4:56   ` Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428220769-3567-1-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox