summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/File.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/File.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/File.hs')
-rw-r--r--src/Propellor/Property/File.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs
index 07ace24b..08fdc780 100644
--- a/src/Propellor/Property/File.hs
+++ b/src/Propellor/Property/File.hs
@@ -97,14 +97,14 @@ dirExists :: FilePath -> Property NoInfo
dirExists d = check (not <$> doesDirectoryExist d) $ property (d ++ " exists") $
makeChange $ createDirectoryIfMissing True d
+-- | The location that a symbolic link points to.
+newtype LinkTarget = LinkTarget FilePath
+
-- | Creates or atomically updates a symbolic link.
--
--- The first parameter is what the link should point to.
---
--- The second parameter is the name of the symbolic link to create.
-- Does not overwrite regular files or directories.
-isSymlinkedTo :: FilePath -> FilePath -> Property NoInfo
-link `isSymlinkedTo` target = property desc $
+isSymlinkedTo :: FilePath -> LinkTarget -> Property NoInfo
+link `isSymlinkedTo` (LinkTarget target) = property desc $
go =<< (liftIO $ tryIO $ getSymbolicLinkStatus link)
where
desc = link ++ " is symlinked to " ++ target