diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-30 17:55:49 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-06-24 06:46:52 -0700 |
| commit | 2d92aefd4bd671e71788007a7d8f7c733c8d7f2d (patch) | |
| tree | 250ad7be9f859a6f310483e8f2ec5afacb283e92 /bitbake/lib | |
| parent | bc322a184da1352e2a977850cf6c44e8bcfdac0d (diff) | |
| download | poky-2d92aefd4bd671e71788007a7d8f7c733c8d7f2d.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: 8714a02e13477a9d97858b3642e05f28247454b5)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit c56bd9a9280378bc64c6a7fe6d7b70847e0b9e6d)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index b41f53a9e2..2e92117634 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
| @@ -135,6 +135,15 @@ class Wget(FetchMethod): | |||
| 135 | 135 | ||
| 136 | self._runwget(ud, d, fetchcmd, False) | 136 | self._runwget(ud, d, fetchcmd, False) |
| 137 | 137 | ||
| 138 | # Sanity check since wget can pretend it succeed when it didn't | ||
| 139 | # Also, this used to happen if sourceforge sent us to the mirror page | ||
| 140 | if not os.path.exists(localpath): | ||
| 141 | raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, localpath), uri) | ||
| 142 | |||
| 143 | if os.path.getsize(localpath) == 0: | ||
| 144 | os.remove(localpath) | ||
| 145 | raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri) | ||
| 146 | |||
| 138 | # Try and verify any checksum now, meaning if it isn't correct, we don't remove the | 147 | # Try and verify any checksum now, meaning if it isn't correct, we don't remove the |
| 139 | # original file, which might be a race (imagine two recipes referencing the same | 148 | # original file, which might be a race (imagine two recipes referencing the same |
| 140 | # source, one with an incorrect checksum) | 149 | # source, one with an incorrect checksum) |
| @@ -144,15 +153,6 @@ class Wget(FetchMethod): | |||
| 144 | # Our lock prevents multiple writers but mirroring code may grab incomplete files | 153 | # Our lock prevents multiple writers but mirroring code may grab incomplete files |
| 145 | os.rename(localpath, localpath[:-4]) | 154 | os.rename(localpath, localpath[:-4]) |
| 146 | 155 | ||
| 147 | # Sanity check since wget can pretend it succeed when it didn't | ||
| 148 | # Also, this used to happen if sourceforge sent us to the mirror page | ||
| 149 | if not os.path.exists(ud.localpath): | ||
| 150 | raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri) | ||
| 151 | |||
| 152 | if os.path.getsize(ud.localpath) == 0: | ||
| 153 | os.remove(ud.localpath) | ||
| 154 | raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri) | ||
| 155 | |||
| 156 | return True | 156 | return True |
| 157 | 157 | ||
| 158 | def checkstatus(self, fetch, ud, d, try_again=True): | 158 | def checkstatus(self, fetch, ud, d, try_again=True): |
