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