summaryrefslogtreecommitdiff
path: root/src/Propellor/Types
diff options
context:
space:
mode:
authorJoey Hess2017-10-25 12:58:50 -0400
committerJoey Hess2017-10-25 13:00:23 -0400
commitd9c8497f8f0019c0646c3f191d890a310d2f3e1e (patch)
tree72b3768fe70f4c39bc0ed10fd3e07342725015c5 /src/Propellor/Types
parent49141aa078c5e288e8ddfe5fde827a93687f0a82 (diff)
Make addInfo accumulate Info in order properties appear, not reverse order
This fixes a bug involving reverting Systemd.resolvConfed or Systemd.linkJournal. addInfo was prepending to the list for efficiency. But, that was in conflict with mappend of two Info, which appended the second to the first. In the case where Systemd.resolvConfed was added reverted, to override the one added by default, that led to a list of info that had first the reversion and then the default, so the default won. Which was wrong. So, make addInfo accumulate in the same order mappend combines things, even though it's a little less efficient. The efficiency probably does not matter; there is not typically a whole lot of info. There's some risk this change has unexpected consequences, if something relied on the old addInfo order without using fromInfo to access to info. But if so, that something would have been broken before when two Info properties were combined. With this change, it would just be broken the other way around. This commit was sponsored by Jochen Bartl on Patreon.
Diffstat (limited to 'src/Propellor/Types')
-rw-r--r--src/Propellor/Types/Info.hs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/Propellor/Types/Info.hs b/src/Propellor/Types/Info.hs
index 5db1eb52..06c45ed2 100644
--- a/src/Propellor/Types/Info.hs
+++ b/src/Propellor/Types/Info.hs
@@ -55,16 +55,15 @@ data PropagateInfo
-- | Any value in the `IsInfo` type class can be added to an Info.
addInfo :: IsInfo v => Info -> v -> Info
-addInfo (Info l) v = Info (InfoEntry v:l)
+addInfo (Info l) v = Info (l++[InfoEntry v])
-- | Converts any value in the `IsInfo` type class into an Info,
-- which is otherwise empty.
toInfo :: IsInfo v => v -> Info
toInfo = addInfo mempty
--- The list is reversed here because addInfo builds it up in reverse order.
fromInfo :: IsInfo v => Info -> v
-fromInfo (Info l) = mconcat (mapMaybe extractInfoEntry (reverse l))
+fromInfo (Info l) = mconcat (mapMaybe extractInfoEntry l)
-- | Maps a function over all values stored in the Info that are of the
-- appropriate type.