mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
bitbake: utils: Fix a potential error in movefile
bitbake utils' movefile is now prone to malform the destination file with duplicated file name strings. Fixing it to force a file name append iff the dest argument is a dir not a file name (Bitbake rev: 38dd27f7191da002a16c561be3790ce487045b01) Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
ea3384e9f8
commit
7c079463c9
@@ -741,9 +741,12 @@ def movefile(src, dest, newmtime = None, sstat = None):
|
|||||||
renamefailed = 1
|
renamefailed = 1
|
||||||
if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]:
|
if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]:
|
||||||
try:
|
try:
|
||||||
# os.rename needs to know the destination path with file name
|
# os.rename needs to know the dest path ending with file name
|
||||||
destfile = os.path.join(dest, os.path.basename(src))
|
# so append the file name to a path only if it's a dir specified
|
||||||
os.rename(src, destfile)
|
srcfname = os.path.basename(src)
|
||||||
|
destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \
|
||||||
|
else dest
|
||||||
|
os.rename(src, destpath)
|
||||||
renamefailed = 0
|
renamefailed = 0
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e[0] != errno.EXDEV:
|
if e[0] != errno.EXDEV:
|
||||||
|
|||||||
Reference in New Issue
Block a user