diff options
Diffstat (limited to 'Annex/MetaData.hs')
-rw-r--r-- | Annex/MetaData.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Annex/MetaData.hs b/Annex/MetaData.hs index f382f0ab1..f1b79e3f4 100644 --- a/Annex/MetaData.hs +++ b/Annex/MetaData.hs @@ -7,6 +7,7 @@ module Annex.MetaData ( genMetaData, + addDateMetaData, module X ) where @@ -37,20 +38,18 @@ genMetaData :: Key -> FilePath -> FileStatus -> Annex () genMetaData key file status = do maybe noop (flip copyMetaData key) =<< catKeyFileHEAD file whenM (annexGenMetaData <$> Annex.getGitConfig) $ do - metadata <- getCurrentMetaData key - let metadata' = genMetaData' status metadata - unless (metadata' == emptyMetaData) $ - addMetaData key metadata' + curr <- getCurrentMetaData key + addMetaData key (addDateMetaData mtime curr) + where + mtime = posixSecondsToUTCTime $ realToFrac $ modificationTime status -{- Generates metadata from the FileStatus. +{- Generates metadata for a file's date stamp. - Does not overwrite any existing metadata values. -} -genMetaData' :: FileStatus -> MetaData -> MetaData -genMetaData' status old = MetaData $ M.fromList $ filter isnew +addDateMetaData :: UTCTime -> MetaData -> MetaData +addDateMetaData mtime old = MetaData $ M.fromList $ filter isnew [ (yearMetaField, S.singleton $ toMetaValue $ show y) , (monthMetaField, S.singleton $ toMetaValue $ show m) ] where isnew (f, _) = S.null (currentMetaDataValues f old) - (y, m, _d) = toGregorian $ utctDay $ - posixSecondsToUTCTime $ realToFrac $ - modificationTime status + (y, m, _d) = toGregorian $ utctDay $ mtime |