public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] fetch(): fix support for digest size=None
@ 2015-04-05  7:59 Michał Górny
  2015-04-05 17:57 ` Zac Medico
  2015-04-06  4:47 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
  0 siblings, 2 replies; 5+ messages in thread
From: Michał Górny @ 2015-04-05  7:59 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: 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.
---
 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-06  4:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-05  7:59 [gentoo-portage-dev] [PATCH] fetch(): fix support for digest size=None Michał Górny
2015-04-05 17:57 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox