diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-07 12:07:38 +0100 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2022-07-08 06:48:38 -1000 |
commit | 7fc4cffebf5dcc1d050416c0b7f7d58c765c1d69 (patch) | |
tree | 7d1b059e4fd3f6b4ba93d1a20681a6f308185309 | |
parent | a247f56df680382d62910bb9a174e0fdd29e4ca8 (diff) | |
download | bitbake-2020-04.18-dunfell.tar.gz |
fetch/wget: Move files into place atomicallyyocto-3.1.182020-04.18-dunfell1.46.18
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-- | lib/bb/fetch2/wget.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py index 5676d3fd2..d208f5ee2 100644 --- a/lib/bb/fetch2/wget.py +++ b/lib/bb/fetch2/wget.py @@ -91,10 +91,9 @@ class Wget(FetchMethod): fetchcmd = self.basecmd - if 'downloadfilename' in ud.parm: - localpath = os.path.join(d.getVar("DL_DIR"), ud.localfile) - bb.utils.mkdirhier(os.path.dirname(localpath)) - fetchcmd += " -O %s" % shlex.quote(localpath) + localpath = os.path.join(d.getVar("DL_DIR"), ud.localfile) + ".tmp" + bb.utils.mkdirhier(os.path.dirname(localpath)) + fetchcmd += " -O %s" % shlex.quote(localpath) if ud.user and ud.pswd: fetchcmd += " --user=%s --password=%s --auth-no-challenge" % (ud.user, ud.pswd) @@ -108,6 +107,10 @@ class Wget(FetchMethod): self._runwget(ud, d, fetchcmd, False) + # Remove the ".tmp" and move the file into position atomically + # 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): |