summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Uwsgi.hs
diff options
context:
space:
mode:
authorJoey Hess2015-10-16 15:31:18 -0400
committerJoey Hess2015-10-16 15:34:24 -0400
commit7f7249f801653e0bd7fa083ed001bf3c5a3c3900 (patch)
tree30c1234ca7e5212f7e597ac397155b1e3270762d /src/Propellor/Property/Uwsgi.hs
parent556cba2f6d0a85545d9a81baf66dbc848fff848e (diff)
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.
Diffstat (limited to 'src/Propellor/Property/Uwsgi.hs')
-rw-r--r--src/Propellor/Property/Uwsgi.hs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Propellor/Property/Uwsgi.hs b/src/Propellor/Property/Uwsgi.hs
index c6ae880b..7de1a85a 100644
--- a/src/Propellor/Property/Uwsgi.hs
+++ b/src/Propellor/Property/Uwsgi.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,16 +14,11 @@ type AppName = String
appEnabled :: AppName -> ConfigFile -> RevertableProperty
appEnabled an cf = enable <!> disable
where
- enable = check test prop
+ enable = appVal an `File.isSymlinkedTo` appValRelativeCfg an
`describe` ("uwsgi app enabled " ++ an)
`requires` appAvailable an cf
`requires` installed
`onChange` reloaded
- where
- test = not <$> doesFileExist (appVal an)
- prop = dir `File.isSymlinkedTo` target
- target = appValRelativeCfg an
- dir = appVal an
disable = trivial $ File.notPresent (appVal an)
`describe` ("uwsgi app disable" ++ an)
`requires` installed
@@ -42,8 +36,8 @@ appCfg an = "/etc/uwsgi/apps-available/" ++ an
appVal :: AppName -> FilePath
appVal an = "/etc/uwsgi/apps-enabled/" ++ an
-appValRelativeCfg :: AppName -> FilePath
-appValRelativeCfg an = "../apps-available/" ++ an
+appValRelativeCfg :: AppName -> File.LinkTarget
+appValRelativeCfg an = File.LinkTarget $ "../apps-available/" ++ an
installed :: Property NoInfo
installed = Apt.installed ["uwsgi"]