summaryrefslogtreecommitdiff
path: root/src/Propellor/Property.hs
diff options
context:
space:
mode:
authorJoey Hess2015-12-05 17:53:32 -0400
committerJoey Hess2015-12-05 17:53:32 -0400
commit97a224b194b96184c7938de0bb1e1f423612ccbc (patch)
tree7cc147c4726af8644510c07ba87597920f8301dc /src/Propellor/Property.hs
parent5c6a43c3b888242443d790efbc1f9282e4e5675c (diff)
parent12548bae3d8feecce6a322162d91b827289ae824 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property.hs')
-rw-r--r--src/Propellor/Property.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs
index 063e7814..c57ef2f0 100644
--- a/src/Propellor/Property.hs
+++ b/src/Propellor/Property.hs
@@ -12,7 +12,6 @@ module Propellor.Property (
, check
, fallback
, trivial
- , changesFile
, revert
-- * Property descriptions
, describe
@@ -26,6 +25,13 @@ module Propellor.Property (
, noChange
, doNothing
, endAction
+ -- * Property result checking
+ , UncheckedProperty
+ , unchecked
+ , changesFile
+ , checkResult
+ , Checkable
+ , assume
) where
import System.Directory
@@ -37,6 +43,7 @@ import "mtl" Control.Monad.RWS.Strict
import System.Posix.Files
import Propellor.Types
+import Propellor.Types.ResultCheck
import Propellor.Info
import Propellor.Exception
import Utility.Exception
@@ -193,17 +200,13 @@ trivial p = adjustPropertySatisfy p $ \satisfy -> do
-- | Indicates that a Property may change a particular file. When the file
-- is modified, the property will return MadeChange instead of NoChange.
-changesFile :: Property i -> FilePath -> Property i
-changesFile p f = adjustPropertySatisfy p $ \satisfy -> do
- s <- getstat
- r <- satisfy
- if r == NoChange
- then do
- s' <- getstat
- return (if samestat s s' then NoChange else MadeChange)
- else return r
+changesFile :: Checkable p i => p i -> FilePath -> Property i
+changesFile p f = checkResult getstat comparestat p
where
getstat = liftIO $ catchMaybeIO $ getSymbolicLinkStatus f
+ comparestat oldstat = do
+ newstat <- getstat
+ return $ if samestat oldstat newstat then NoChange else MadeChange
samestat Nothing Nothing = True
samestat (Just a) (Just b) = and
-- everything except for atime