From 12548bae3d8feecce6a322162d91b827289ae824 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 Dec 2015 17:52:43 -0400 Subject: UncheckedProperty for cmdProperty et al * Properties that run an arbitrary command, such as cmdProperty and scriptProperty are converted to use UncheckedProperty, since they cannot tell on their own if the command truely made a change or not. (API Change) Transition guide: - When GHC complains about an UncheckedProperty, add: `assume` MadeChange - Since these properties used to always return MadeChange, that change is always safe to make. - Or, if you know that the command should modifiy a file, use: `changesFile` filename * A few properties have had their Result improved, for example Apt.buldDep and Apt.autoRemove now check if a change was made or not. --- src/Propellor/Property/File.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Propellor/Property/File.hs') diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs index e29eceb8..56066b5b 100644 --- a/src/Propellor/Property/File.hs +++ b/src/Propellor/Property/File.hs @@ -158,19 +158,19 @@ f `isCopyOf` f' = property desc $ go =<< (liftIO $ tryIO $ getFileStatus f') -- | Ensures that a file/dir has the specified owner and group. ownerGroup :: FilePath -> User -> Group -> Property NoInfo -ownerGroup f (User owner) (Group group) = property (f ++ " owner " ++ og) $ do - r <- ensureProperty $ cmdProperty "chown" [og, f] - if r == FailedChange - then return r - else noChange +ownerGroup f (User owner) (Group group) = p `describe` (f ++ " owner " ++ og) where + p = cmdProperty "chown" [og, f] + `changesFile` f og = owner ++ ":" ++ group -- | Ensures that a file/dir has the specfied mode. mode :: FilePath -> FileMode -> Property NoInfo -mode f v = property (f ++ " mode " ++ show v) $ do - liftIO $ modifyFileMode f (const v) - noChange +mode f v = p `changesFile` f + where + p = property (f ++ " mode " ++ show v) $ do + liftIO $ modifyFileMode f (const v) + return NoChange -- | A temp file to use when writing new content for a file. -- -- cgit v1.2.3