diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-07 12:07:38 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-07-15 12:41:59 +0100 |
commit | 50aa474c841c6c232f67a1855841acbdd483a4a9 (patch) | |
tree | 06b4b9c8b1064f90cc8fd1a6dd5a33dd6b24cfc4 /bitbake/lib | |
parent | 9c5b33ccbabfa112da30423e8dad88e235a2b16f (diff) | |
download | poky-50aa474c841c6c232f67a1855841acbdd483a4a9.tar.gz |
bitbake: fetch/wget: Move files into place atomically
(Bitbake rev: 7fc4cffebf5dcc1d050416c0b7f7d58c765c1d69)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit cd7cce4cf4be5c742d29671169354fe84220b47a)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-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 5676d3fd27..d208f5ee2f 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -91,10 +91,9 @@ class Wget(FetchMethod): | |||
91 | 91 | ||
92 | fetchcmd = self.basecmd | 92 | fetchcmd = self.basecmd |
93 | 93 | ||
94 | if 'downloadfilename' in ud.parm: | 94 | localpath = os.path.join(d.getVar("DL_DIR"), ud.localfile) + ".tmp" |
95 | localpath = os.path.join(d.getVar("DL_DIR"), ud.localfile) | 95 | bb.utils.mkdirhier(os.path.dirname(localpath)) |
96 | bb.utils.mkdirhier(os.path.dirname(localpath)) | 96 | fetchcmd += " -O %s" % shlex.quote(localpath) |
97 | fetchcmd += " -O %s" % shlex.quote(localpath) | ||
98 | 97 | ||
99 | if ud.user and ud.pswd: | 98 | if ud.user and ud.pswd: |
100 | fetchcmd += " --user=%s --password=%s --auth-no-challenge" % (ud.user, ud.pswd) | 99 | fetchcmd += " --user=%s --password=%s --auth-no-challenge" % (ud.user, ud.pswd) |
@@ -108,6 +107,10 @@ class Wget(FetchMethod): | |||
108 | 107 | ||
109 | self._runwget(ud, d, fetchcmd, False) | 108 | self._runwget(ud, d, fetchcmd, False) |
110 | 109 | ||
110 | # Remove the ".tmp" and move the file into position atomically | ||
111 | # Our lock prevents multiple writers but mirroring code may grab incomplete files | ||
112 | os.rename(localpath, localpath[:-4]) | ||
113 | |||
111 | # Sanity check since wget can pretend it succeed when it didn't | 114 | # Sanity check since wget can pretend it succeed when it didn't |
112 | # Also, this used to happen if sourceforge sent us to the mirror page | 115 | # Also, this used to happen if sourceforge sent us to the mirror page |
113 | if not os.path.exists(ud.localpath): | 116 | if not os.path.exists(ud.localpath): |