* [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
* Re: [gentoo-portage-dev] [PATCH] fetch(): fix support for digest size=None
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
1 sibling, 1 reply; 5+ messages in thread
From: Zac Medico @ 2015-04-05 17:57 UTC (permalink / raw
To: gentoo-portage-dev
On 04/05/2015 12:59 AM, Michał Górny wrote:
> 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.
If we're handling this case, then we should probably not assume that the
dict contains a "size" key. So, we could check that dict.get("size") is
not None.
--
Thanks,
Zac
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] fetch(): fix support for digest size=None
2015-04-05 17:57 ` Zac Medico
@ 2015-04-05 21:55 ` Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2015-04-05 21:55 UTC (permalink / raw
To: Zac Medico; +Cc: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 665 bytes --]
Dnia 2015-04-05, o godz. 10:57:57
Zac Medico <zmedico@gentoo.org> napisał(a):
> On 04/05/2015 12:59 AM, Michał Górny wrote:
> > 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.
>
> If we're handling this case, then we should probably not assume that the
> dict contains a "size" key. So, we could check that dict.get("size") is
> not None.
I agree. Could you take it from this point? I don't really have time to
do this, so I limit myself to solving the bugs I need to get moving :/.
--
Best regards,
Michał Górny
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-portage-dev] [PATCH v2] fetch(): fix support for digest size=None
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-06 4:47 ` Zac Medico
2015-04-06 4:56 ` Brian Dolbec
1 sibling, 1 reply; 5+ messages in thread
From: Zac Medico @ 2015-04-06 4:47 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny, Zac Medico
From: Michał Górny <mgorny@gentoo.org>
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 <zmedico@gentoo.org>
---
[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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [gentoo-portage-dev] [PATCH v2] fetch(): fix support for digest size=None
2015-04-06 4:47 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
@ 2015-04-06 4:56 ` Brian Dolbec
0 siblings, 0 replies; 5+ messages in thread
From: Brian Dolbec @ 2015-04-06 4:56 UTC (permalink / raw
To: gentoo-portage-dev
On Sun, 5 Apr 2015 21:47:12 -0700
Zac Medico <zmedico@gentoo.org> wrote:
> From: Michał Górny <mgorny@gentoo.org>
>
> 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 <zmedico@gentoo.org>
> ---
> [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"]:
OK :) merge please
--
Brian Dolbec <dolsen>
^ permalink raw reply [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