Skip to content

Commit 346020a

Browse files
committed
[build] Add safeguard for staging-dir symlink edge case
As suggested by CodeRabbit review, add check to ensure staging-dir is a real directory before creating symlinks inside it.
1 parent ab4b835 commit 346020a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,12 @@ def clone_or_update_repo(name, branch, dir_name, owner="openwisp", dest=None):
271271
If the repository already exists, update it. Otherwise, clone the repository.
272272
"""
273273
repository = f"{owner}/{name}"
274-
275274
# Support for building with local changes
276275
if name == "openwisp-docs" and not os.environ.get("PRODUCTION"):
277276
print(f"Using local directory for '{name}'")
278277

278+
if os.path.islink("staging-dir"):
279+
os.unlink("staging-dir")
279280
os.makedirs("staging-dir", exist_ok=True)
280281
exclude_items = {"staging-dir", "modules", "_build", ".git", "__pycache__"}
281282
for item in os.listdir("."):

0 commit comments

Comments
 (0)