utils.movefile: specify dest file name]
PATCH 1/1 utils.movefile: specify dest file name]
Sending this to the right list.
Benjamin
-------- Forwarded Message --------
From: Benjamin Esquivel <[email protected]>
To: [email protected]
Cc: [email protected], Benjamin Esquivel < [email protected]>
Subject: [PATCH] utils.movefile: specify dest file name
Date: Thu, 20 Aug 2015 13:59:58 +0000
Quoted 30 lines
When moving a file via the os.rename function, it was missing the destination file name which caused an OSError
[YOCTO#8180]
Signed-off-by Benjamin Esquivel <[email protected]>--- bitbake/lib/bb/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)bitbake/lib/bb/utils.py +0
-0@@ -741,7 +741,9 @@ def movefile(src, dest, newmtime = None, sstat =None):
renamefailed = 1
if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]:
try:bitbake/lib/bb/utils.py +1
-1- os.rename(src, dest) + # os.rename needs to know the destination path with filename
bitbake/lib/bb/utils.py +2
-0+ destfile = os.path.join(dest, os.path.basename(src)) + os.rename(src, destfile) renamefailed = 0 except Exception as e: if e[0] != errno.EXDEV:Signature · 1 line
2.3.0
PATCH 1/1 bitbake: fixing 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/lib/bb/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bb/utils.py +6 -3
@@ -741,9 +741,12 @@ def movefile(src, dest, newmtime = None, sstat = None): renamefailed = 1 if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]: try: - # os.rename needs to know the destination path with file name - destfile = os.path.join(dest, os.path.basename(src)) - os.rename(src, destfile) + # os.rename needs to know the dest path ending with file name + # so append the file name to a path only if it's a dir specified + srcfname = os.path.basename(src) + destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \ + else dest + os.rename(src, destpath) renamefailed = 0 except Exception as e: if e[0] != errno.EXDEV:
Signature · 1 line
2.3.0