bitbake: cache: Remove invalid symlink for bb_cache.dat

The bb_cache.dat might be an invalid symlink when error happens, then
os.path.exists(symlink) would return False for it, the invalid symlink
wouldn't be removed and os.symlink can't update it any more.

Use os.path.islink(symlink) can fix the problem.

(Bitbake rev: 1387d7b9ee3f270488f89b29f36f9f240e44accc)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Robert Yang
2024-06-23 17:03:49 -07:00
committed by Richard Purdie
parent 2346c7ca09
commit ac40cb5ee2

View File

@@ -441,7 +441,7 @@ class Cache(object):
else:
symlink = os.path.join(self.cachedir, "bb_cache.dat")
if os.path.exists(symlink):
if os.path.exists(symlink) or os.path.islink(symlink):
bb.utils.remove(symlink)
try:
os.symlink(os.path.basename(self.cachefile), symlink)