aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-11-04 17:34:41 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-11-29 11:00:48 -0700
commite79f3c336e6d6c70421d25dd892c842f76516504 (patch)
treed95fc3b95fafdfeeb7882dd977aaad64d17f9074 /src
parent60da5db58bb50764ede4d3c37ea2416153774958 (diff)
downloadconsfigurator-e79f3c336e6d6c70421d25dd892c842f76516504.tar.gz
FILE:SYMLINKED: delete existing links that point elsewhere
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r--src/property/file.lisp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp
index 2612805..e2435c7 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -249,8 +249,12 @@ directory, you can use one or more '../', or an absolute path."
(failed-change "~A exists but is not a symbolic link." from))
(if (and link (string= (remote-link-target from) to))
:no-change
- (progn
- (containing-directory-exists from) (mrun "ln" "-sf" to from)))))
+ (progn (containing-directory-exists from)
+ ;; With at least GNU ln(1), passing -f, but not also -T, does
+ ;; not replace an existing link in some cases.
+ ;; -T is not POSIX, so we just remove any existing link first.
+ (does-not-exist from)
+ (mrun "ln" "-sf" to from)))))
(:unapply
(declare (ignore to))
(if (remote-test "-L" from)