aboutsummaryrefslogtreecommitdiff
path: root/src/property/file.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/property/file.lisp')
-rw-r--r--src/property/file.lisp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp
index 9712571..2612805 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -111,11 +111,17 @@ any of the regular expressions PATTERNS."
(:hostattrs
(unless (or user group)
(inapplicable-property "Not enough arguments.")))
+ ;; We don't want to execute chown(1) unless we're sure it's needed because
+ ;; in some circumstances doing so also changes the file mode.
+ (:check (multiple-value-bind (mode size mtime owner gowner)
+ (remote-file-stats path)
+ (declare (ignore mode size mtime))
+ (and (or (not user) (string= user owner))
+ (or (not group) (string= group gowner)))))
(:apply
- (with-change-if-changes-file (path)
- (if user
- (mrun "chown" "-h" (format nil "~A~:[~;:~:*~A~]" user group) path)
- (mrun "chgrp" "-h" group path)))))
+ (if user
+ (mrun "chown" "-h" (format nil "~A~:[~;:~:*~A~]" user group) path)
+ (mrun "chgrp" "-h" group path))))
(defprop does-not-exist :posix (&rest paths)
"Ensure that files do not exist."