1 |
On Sun, 5 Apr 2015 21:47:12 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> From: Michał Górny <mgorny@g.o> |
5 |
> |
6 |
> It seems that the code initially supported fetching without size |
7 |
> 'digest' but it got broken over time. Add proper conditionals to avoid |
8 |
> ugly failures in this case. |
9 |
> |
10 |
> Signed-off-by: Zac Medico <zmedico@g.o> |
11 |
> --- |
12 |
> [PATCH v2] uses dict.get() so that the "size" key is not required |
13 |
> |
14 |
> https://github.com/zmedico/portage/tree/mgorny-fetch-size-missing |
15 |
> |
16 |
> pym/portage/checksum.py | 2 +- |
17 |
> pym/portage/package/ebuild/fetch.py | 7 ++++--- |
18 |
> 2 files changed, 5 insertions(+), 4 deletions(-) |
19 |
> |
20 |
> diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py |
21 |
> index f24a90f..642602e 100644 |
22 |
> --- a/pym/portage/checksum.py |
23 |
> +++ b/pym/portage/checksum.py |
24 |
> @@ -303,7 +303,7 @@ def verify_all(filename, mydict, calc_prelink=0, |
25 |
> strict=0): reason = "Reason unknown" |
26 |
> try: |
27 |
> mysize = os.stat(filename)[stat.ST_SIZE] |
28 |
> - if mydict["size"] != mysize: |
29 |
> + if mydict.get("size") is not None and |
30 |
> mydict["size"] != mysize: return False,(_("Filesize does not match |
31 |
> recorded size"), mysize, mydict["size"]) except OSError as e: |
32 |
> if e.errno == errno.ENOENT: |
33 |
> diff --git a/pym/portage/package/ebuild/fetch.py |
34 |
> b/pym/portage/package/ebuild/fetch.py index 7b856a2..7e4e6fe 100644 |
35 |
> --- a/pym/portage/package/ebuild/fetch.py |
36 |
> +++ b/pym/portage/package/ebuild/fetch.py |
37 |
> @@ -700,7 +700,7 @@ def fetch(myuris, mysettings, listonly=0, |
38 |
> fetchonly=0, os.unlink(myfile_path) |
39 |
> except |
40 |
> OSError: pass |
41 |
> - elif distdir_writable: |
42 |
> + elif distdir_writable and |
43 |
> size is not None: if mystat.st_size < fetch_resume_size and \ |
44 |
> mystat.st_size |
45 |
> < size: # If the file already exists and the size does not |
46 |
> @@ -806,8 +806,9 @@ def fetch(myuris, mysettings, listonly=0, |
47 |
> fetchonly=0, # assume that it is fully downloaded. |
48 |
> continue |
49 |
> else: |
50 |
> - if mystat.st_size < |
51 |
> mydigests[myfile]["size"] and \ |
52 |
> - not |
53 |
> restrict_fetch: |
54 |
> + if |
55 |
> (mydigests[myfile].get("size") is not None |
56 |
> + and |
57 |
> mystat.st_size < mydigests[myfile]["size"] |
58 |
> + and |
59 |
> not restrict_fetch): fetched = 1 # Try to resume this download. |
60 |
> elif |
61 |
> parallel_fetchonly and \ mystat.st_size == mydigests[myfile]["size"]: |
62 |
|
63 |
OK :) merge please |
64 |
|
65 |
-- |
66 |
Brian Dolbec <dolsen> |