summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-30 17:55:49 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-31 16:56:25 +0100
commitf81127b6195dd94280389c3dd4a82abdad85faa8 (patch)
tree466151fe521c1b7538d4c87d0e89b8738d7de996 /bitbake
parentc2d2ae7b1d16c30ca9333a61a2765bdf59dddcba (diff)
downloadpoky-f81127b6195dd94280389c3dd4a82abdad85faa8.tar.gz
bitbake: fetch2/wget: Fix failure path for files that are empty or don't exist
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. (Bitbake rev: c56bd9a9280378bc64c6a7fe6d7b70847e0b9e6d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index fbfa6938ac..d76b1d0d38 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -134,6 +134,15 @@ class Wget(FetchMethod):
134 134
135 self._runwget(ud, d, fetchcmd, False) 135 self._runwget(ud, d, fetchcmd, False)
136 136
137 # Sanity check since wget can pretend it succeed when it didn't
138 # Also, this used to happen if sourceforge sent us to the mirror page
139 if not os.path.exists(localpath):
140 raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, localpath), uri)
141
142 if os.path.getsize(localpath) == 0:
143 os.remove(localpath)
144 raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
145
137 # Try and verify any checksum now, meaning if it isn't correct, we don't remove the 146 # Try and verify any checksum now, meaning if it isn't correct, we don't remove the
138 # original file, which might be a race (imagine two recipes referencing the same 147 # original file, which might be a race (imagine two recipes referencing the same
139 # source, one with an incorrect checksum) 148 # source, one with an incorrect checksum)
@@ -143,15 +152,6 @@ class Wget(FetchMethod):
143 # Our lock prevents multiple writers but mirroring code may grab incomplete files 152 # Our lock prevents multiple writers but mirroring code may grab incomplete files
144 os.rename(localpath, localpath[:-4]) 153 os.rename(localpath, localpath[:-4])
145 154
146 # Sanity check since wget can pretend it succeed when it didn't
147 # Also, this used to happen if sourceforge sent us to the mirror page
148 if not os.path.exists(ud.localpath):
149 raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri)
150
151 if os.path.getsize(ud.localpath) == 0:
152 os.remove(ud.localpath)
153 raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
154
155 return True 155 return True
156 156
157 def checkstatus(self, fetch, ud, d, try_again=True): 157 def checkstatus(self, fetch, ud, d, try_again=True):