diff mbox series

[5/5] git: Clean broken symlink

Message ID e0f7bc3c5f28bf27b17bd1ef39a9abea18011976.1729933869.git.liezhi.yang@windriver.com
State Accepted, archived
Commit d0deb5fe6e7a84b07b49ef685b209729d2fdc780
Headers show
Series [1/5] gitsm: Add call_process_submodules() to remove duplicated code | expand

Commit Message

Robert Yang Oct. 26, 2024, 9:39 a.m. UTC
From: Robert Yang <liezhi.yang@windriver.com>

The file may be a symlink when mirror from local disk, and the symlink will be
broken when the linked file is removed, use os.path.islink() to check and
remove the broken symlink.

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

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 0ea55e139..6badda597 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -733,7 +733,7 @@  class Git(FetchMethod):
             to_remove.append(ud.fullshallow + ".done")
 
         for r in to_remove:
-            if os.path.exists(r):
+            if os.path.exists(r) or os.path.islink(r):
                 bb.note('Removing %s' % r)
                 bb.utils.remove(r, True)