diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-07 12:07:38 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-10-10 12:01:06 -0700 |
| commit | 5a511dadc0f694cb3fa214a3ffd4a2f62bd7aa19 (patch) | |
| tree | 79b041cdfe103e39a0e27cbffc22be6ff6b2225f | |
| parent | 78fc4af7770ed3c98e1617d9d47b106b405d55d6 (diff) | |
| download | poky-5a511dadc0f694cb3fa214a3ffd4a2f62bd7aa19.tar.gz | |
bitbake: fetch/wget: Move files into place atomically
(Bitbake rev: aaf9c1b8673f5b181255a08eee4e9a342863e896)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit cd7cce4cf4be5c742d29671169354fe84220b47a)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index 9bcb0d4b7a..708f3a42e6 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
| @@ -109,10 +109,9 @@ class Wget(FetchMethod): | |||
| 109 | 109 | ||
| 110 | fetchcmd = self.basecmd | 110 | fetchcmd = self.basecmd |
| 111 | 111 | ||
| 112 | if 'downloadfilename' in ud.parm: | 112 | localpath = os.path.join(d.getVar("DL_DIR"), ud.localfile) + ".tmp" |
| 113 | localpath = os.path.join(d.getVar("DL_DIR"), ud.localfile) | 113 | bb.utils.mkdirhier(os.path.dirname(localpath)) |
| 114 | bb.utils.mkdirhier(os.path.dirname(localpath)) | 114 | fetchcmd += " -O %s" % shlex.quote(localpath) |
| 115 | fetchcmd += " -O %s" % shlex.quote(localpath) | ||
| 116 | 115 | ||
| 117 | if ud.user and ud.pswd: | 116 | if ud.user and ud.pswd: |
| 118 | fetchcmd += " --auth-no-challenge" | 117 | fetchcmd += " --auth-no-challenge" |
| @@ -136,6 +135,10 @@ class Wget(FetchMethod): | |||
| 136 | 135 | ||
| 137 | self._runwget(ud, d, fetchcmd, False) | 136 | self._runwget(ud, d, fetchcmd, False) |
| 138 | 137 | ||
| 138 | # Remove the ".tmp" and move the file into position atomically | ||
| 139 | # Our lock prevents multiple writers but mirroring code may grab incomplete files | ||
| 140 | os.rename(localpath, localpath[:-4]) | ||
| 141 | |||
| 139 | # Sanity check since wget can pretend it succeed when it didn't | 142 | # Sanity check since wget can pretend it succeed when it didn't |
| 140 | # Also, this used to happen if sourceforge sent us to the mirror page | 143 | # Also, this used to happen if sourceforge sent us to the mirror page |
| 141 | if not os.path.exists(ud.localpath): | 144 | if not os.path.exists(ud.localpath): |
