summaryrefslogtreecommitdiff
path: root/Logs/MetaData.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-19 19:10:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-19 19:10:55 -0400
commit000155ea54690088b95b10fefa67711c5ab2a7ba (patch)
tree56e06297e36e1198fe2fce4ffe9c7c024fd2bed8 /Logs/MetaData.hs
parent6ed3cabd704f61ffa3e99d4222c8cf71a27526f1 (diff)
toplevel lastchanged field
Diffstat (limited to 'Logs/MetaData.hs')
-rw-r--r--Logs/MetaData.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs
index e1d2044cc..b682ca005 100644
--- a/Logs/MetaData.hs
+++ b/Logs/MetaData.hs
@@ -67,16 +67,22 @@ getCurrentMetaData k = do
return $ currentMetaData $ unionMetaData loggedmeta
(lastchanged ls loggedmeta)
where
- lastchanged ls (MetaData wanted) =
+ lastchanged [] _ = emptyMetaData
+ lastchanged ls (MetaData currentlyset) =
let m = foldl' (flip M.union) M.empty (map genlastchanged ls)
- in MetaData $ M.mapKeys lastChangedField $
+ in MetaData $
+ -- Add a overall lastchanged using the oldest log
+ -- item (log is in ascending order).
+ M.insert lastChangedField (lastchangedval $ Prelude.last ls) $
+ M.mapKeys mkLastChangedField $
-- Only include fields that are currently set.
- m `M.intersection` wanted
+ m `M.intersection` currentlyset
-- Makes each field have the timestamp as its value.
genlastchanged l =
let MetaData m = value l
- ts = S.singleton $ toMetaValue $ showts $ changed l
+ ts = lastchangedval l
in M.map (const ts) m
+ lastchangedval l = S.singleton $ toMetaValue $ showts $ changed l
showts = formatTime defaultTimeLocale "%F@%H-%M-%S" . posixSecondsToUTCTime
{- Adds in some metadata, which can override existing values, or unset