diff mbox series

[1/1] cache: Remove invalid symlink for bb_cache.dat

Message ID 78a640127fd83e682ededc5a21aad253c3412ed4.1719187359.git.liezhi.yang@windriver.com
State New
Headers show
Series [1/1] cache: Remove invalid symlink for bb_cache.dat | expand

Commit Message

Robert Yang June 24, 2024, 12:03 a.m. UTC
From: Robert Yang <liezhi.yang@windriver.com>

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.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 bitbake/lib/bb/cache.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 18d5574a31..4a96f5b313 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -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)