You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2026/10/02 16:21:18 UTC
(buildstream) 04/04: cascache.py: Replace existing files in `checkout` for symlinks
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch jbilleter/checkout
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 43b2292f0e533edf00bb67be7307aaef32414981
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Fri Oct 2 14:25:16 2026 +0200
cascache.py: Replace existing files in `checkout` for symlinks
`bst artifact checkout --force` intentionally replaces existing files.
The same should apply to symlinks. Without `--force`, it should not be
possible to hit that code path.
---
src/buildstream/_cas/cascache.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 489bb938d..7656e9f10 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -231,7 +231,14 @@ class CASCache:
# symlink
_validate_cas_node_name(symlinknode.name, names)
fullpath = os.path.join(dest, symlinknode.name)
- os.symlink(symlinknode.target, fullpath)
+ try:
+ os.symlink(symlinknode.target, fullpath)
+ except FileExistsError:
+ try:
+ os.unlink(fullpath)
+ except OSError as e:
+ raise CASCacheError(f"Failed to remove destination file '{fullpath}': {e}") from e
+ os.symlink(symlinknode.target, fullpath)
node_properties = directory.node_properties
if node_properties.HasField("mtime"):