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:
parent
812d90022b
commit
4d0e522b72
4 changed files with 47 additions and 8 deletions
|
@ -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. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue