really add non-date metadata too

This commit is contained in:
Joey Hess 2014-07-03 14:35:20 -04:00
parent 4565b5263d
commit fc80956092
Failed to extract signature
2 changed files with 5 additions and 5 deletions

View file

@ -7,7 +7,7 @@
module Annex.MetaData (
genMetaData,
addDateMetaData,
dateMetaData,
module X
) where
@ -39,14 +39,14 @@ genMetaData key file status = do
maybe noop (flip copyMetaData key) =<< catKeyFileHEAD file
whenM (annexGenMetaData <$> Annex.getGitConfig) $ do
curr <- getCurrentMetaData key
addMetaData key (addDateMetaData mtime curr)
addMetaData key (dateMetaData mtime curr)
where
mtime = posixSecondsToUTCTime $ realToFrac $ modificationTime status
{- Generates metadata for a file's date stamp.
- Does not overwrite any existing metadata values. -}
addDateMetaData :: UTCTime -> MetaData -> MetaData
addDateMetaData mtime old = MetaData $ M.fromList $ filter isnew
dateMetaData :: UTCTime -> MetaData -> MetaData
dateMetaData mtime old = MetaData $ M.fromList $ filter isnew
[ (yearMetaField, S.singleton $ toMetaValue $ show y)
, (monthMetaField, S.singleton $ toMetaValue $ show m)
]

View file

@ -228,7 +228,7 @@ feedFile tmpl i extension = Utility.Format.format tmpl $
extractMetaData :: ToDownload -> MetaData
extractMetaData i = case getItemPublishDate (item i) :: Maybe (Maybe UTCTime) of
Just (Just d) -> addDateMetaData d meta
Just (Just d) -> unionMetaData meta (dateMetaData d meta)
_ -> meta
where
tometa (k, v) = (mkMetaFieldUnchecked k, S.singleton (toMetaValue v))