From 7f7249f801653e0bd7fa083ed001bf3c5a3c3900 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 16 Oct 2015 15:31:18 -0400 Subject: add a LinkTarget type to disambiguate parameters of isSymlinkedTo Something about making symlinks is very confusing about which parameter is which. It perhaps doesn't help that isSymlinkedTo has the target second, while ln has it first. Let's use a type to prevent confusion. Also, simplified some properties that now use isSymlinkedTo. Since isSymlinkedTo checks the link target, these properties don't need to check themselves that the link is in place. --- src/Propellor/Property/Prosody.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/Propellor/Property/Prosody.hs') diff --git a/src/Propellor/Property/Prosody.hs b/src/Propellor/Property/Prosody.hs index 7dbfb1e1..0e379e63 100644 --- a/src/Propellor/Property/Prosody.hs +++ b/src/Propellor/Property/Prosody.hs @@ -6,7 +6,6 @@ import Propellor.Base import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Service as Service -import System.Posix.Files type ConfigFile = [String] @@ -15,17 +14,16 @@ type Conf = String confEnabled :: Conf -> ConfigFile -> RevertableProperty confEnabled conf cf = enable disable where - enable = check test prop + enable = dir `File.isSymlinkedTo` target `describe` ("prosody conf enabled " ++ conf) `requires` confAvailable conf cf `requires` installed `onChange` reloaded where - test = not <$> doesFileExist (confValPath conf) - prop = dir `File.isSymlinkedTo` target target = confValRelativePath conf dir = confValPath conf - confValRelativePath conf' = "../conf.avail" conf' <.> "cfg.lua" + confValRelativePath conf' = File.LinkTarget $ + "../conf.avail" conf' <.> "cfg.lua" disable = trivial $ File.notPresent (confValPath conf) `describe` ("prosody conf disabled " ++ conf) `requires` installed -- cgit v1.2.3