aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-30 17:55:49 +0100
committerSteve Sakoman <steve@sakoman.com>2024-06-14 08:48:23 -0700
commit8714a02e13477a9d97858b3642e05f28247454b5 (patch)
tree776d7d21f4b807bdb71855b6bbb2ddf8815829c1
parent5fa596b3f2e49fbd144347b9800c76de72a29e28 (diff)
downloadbitbake-8714a02e13477a9d97858b3642e05f28247454b5.tar.gz
fetch2/wget: Fix failure path for files that are empty or don't existyocto-5.0.22024-04.2-scarthgap2.8.2
When we intercepted the file download to a temp file, we broke the exist/size checks which need to happen before the rename. Correct the ordering. For some reason, python 3.12 exposes this problem in the selftests differently to previous versions. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit c56bd9a9280378bc64c6a7fe6d7b70847e0b9e6d) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--lib/bb/fetch2/wget.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index b41f53a9e..2e9211763 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -135,6 +135,15 @@ class Wget(FetchMethod):
self._runwget(ud, d, fetchcmd, False)
+ # Sanity check since wget can pretend it succeed when it didn't
+ # Also, this used to happen if sourceforge sent us to the mirror page
+ if not os.path.exists(localpath):
+ raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, localpath), uri)
+
+ if os.path.getsize(localpath) == 0:
+ os.remove(localpath)
+ raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
+
# Try and verify any checksum now, meaning if it isn't correct, we don't remove the
# original file, which might be a race (imagine two recipes referencing the same
# source, one with an incorrect checksum)
@@ -144,15 +153,6 @@ class Wget(FetchMethod):
# Our lock prevents multiple writers but mirroring code may grab incomplete files
os.rename(localpath, localpath[:-4])
- # Sanity check since wget can pretend it succeed when it didn't
- # Also, this used to happen if sourceforge sent us to the mirror page
- if not os.path.exists(ud.localpath):
- raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri)
-
- if os.path.getsize(ud.localpath) == 0:
- os.remove(ud.localpath)
- raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
-
return True
def checkstatus(self, fetch, ud, d, try_again=True):