fs: make symlinking more resilient when something's already at the location

This commit is contained in:
colin 2023-01-06 14:51:25 +00:00
parent 1d0cadce85
commit 19c254c266

View File

@ -298,7 +298,10 @@ let
lnfrom="$1"
lnto="$2"
ln -sf --no-dereference "$lnto" "$lnfrom"
# ln is clever when there's something else at the place we want to create the link
# only create the link if nothing's there or what is there is another link,
# otherwise you'll get links at unexpected fs locations
! test -e "$lnfrom" || test -L "$lnfrom" && ln -sf --no-dereference "$lnto" "$lnfrom"
'';
scriptArgs = [ path link-cfg.target ];
};