don't copy old date metadata when adding new version of a file

When adding a new version of a file, and annex.genmetadata is enabled,
don't copy the data metadata from the old version of the file, instead use
the mtime of the file. Rationalle being that the user has requested to
generate metadata and so would expect to get the new mtime into metadata.

Also, avoid warning about copying metadata when all the old metadata is
date metadata. Which was rather the harder part.

This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
This commit is contained in:
Joey Hess 2018-04-04 13:42:15 -04:00
parent c6252018fa
commit ef389722ae
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 66 additions and 13 deletions

View file

@ -10,6 +10,7 @@ module Annex.MetaData.StandardFields (
yearMetaField,
monthMetaField,
dayMetaField,
isDateMetaField,
lastChangedField,
mkLastChangedField,
isLastChangedField
@ -31,6 +32,12 @@ monthMetaField = mkMetaFieldUnchecked "month"
dayMetaField :: MetaField
dayMetaField = mkMetaFieldUnchecked "day"
isDateMetaField :: MetaField -> Bool
isDateMetaField yearMetaField = True
isDateMetaField monthMetaField = True
isDateMetaField datMetaField = True
isDateMetaField _ = False
lastChangedField :: MetaField
lastChangedField = mkMetaFieldUnchecked lastchanged