summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/File.hs
diff options
context:
space:
mode:
authorJoey Hess2014-12-09 00:30:04 -0400
committerJoey Hess2014-12-09 00:30:04 -0400
commitf8943c2036d91585f7afc3140b2442e7e78c284f (patch)
treeca0ca45f95c98163b5a4f35a7ba8470ed743c304 /src/Propellor/Property/File.hs
parent040a5fe3c75930f08667369357a77ededf815c5a (diff)
fix a case where fileProperty reported a change despite not making one
The problem occurred because two lists of lines of the file can be different, while representing the same file content. For example: ["foo", "bar"] ["foo\nbar"]
Diffstat (limited to 'src/Propellor/Property/File.hs')
-rw-r--r--src/Propellor/Property/File.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs
index d2296354..a1a86763 100644
--- a/src/Propellor/Property/File.hs
+++ b/src/Propellor/Property/File.hs
@@ -62,11 +62,11 @@ fileProperty' :: (FilePath -> String -> IO ()) -> Desc -> ([Line] -> [Line]) ->
fileProperty' writer desc a f = property desc $ go =<< liftIO (doesFileExist f)
where
go True = do
- ls <- liftIO $ lines <$> readFile f
- let ls' = a ls
- if ls' == ls
+ old <- liftIO $ readFile f
+ let new = unlines (a (lines old))
+ if old == new
then noChange
- else makeChange $ viaTmp updatefile f (unlines ls')
+ else makeChange $ viaTmp updatefile f new
go False = makeChange $ writer f (unlines $ a [])
-- viaTmp makes the temp file mode 600.