Warn when metadata is inherited from a previous version of a file

to avoid the user being surprised in cases where that behavior is not desired or expected

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2017-09-28 12:56:35 -04:00
parent 812d90022b
commit 4d0e522b72
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 47 additions and 8 deletions

View file

@ -39,12 +39,20 @@ import Data.Time.Clock.POSIX
-}
genMetaData :: Key -> FilePath -> FileStatus -> Annex ()
genMetaData key file status = do
maybe noop (`copyMetaData` key) =<< catKeyFileHEAD file
v <- catKeyFileHEAD file
case v of
Nothing -> noop
Just oldkey ->
whenM (copyMetaData oldkey key)
warncopied
whenM (annexGenMetaData <$> Annex.getGitConfig) $ do
curr <- getCurrentMetaData key
addMetaData key (dateMetaData mtime curr)
where
mtime = posixSecondsToUTCTime $ realToFrac $ modificationTime status
warncopied = warning $
"Copied metadata from old version of " ++ file ++ " to new version. " ++
"If you don't want this copied metadata, run: git annex metadata --remove-all " ++ file
{- Generates metadata for a file's date stamp.
- Does not overwrite any existing metadata values. -}