error when metadata set is used with file that does not exist

When setting metadata of a file that did not exist, no error message was
displayed, unlike getting metadata and most other git-annex commands. Fixed
this oversight.

Note that, if the file exists but is not annexed, there's no error.
This is the same behavior as other git-annex commands.

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2017-06-01 11:40:47 -04:00
parent 970fd765d7
commit bb060f000f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 14 additions and 6 deletions

View file

@ -9,6 +9,9 @@ git-annex (6.20170520) UNRELEASED; urgency=medium
transfers.
* Avoid concurrent git-config setting problem when running concurrent
threads.
* metadata: When setting metadata of a file that did not exist,
no error message was displayed, unlike getting metadata and most other
git-annex commands. Fixed this oversight.
-- Joey Hess <id@joeyh.name> Wed, 24 May 2017 14:03:40 -0400

View file

@ -41,7 +41,9 @@ withFilesInGitNonRecursive needforce a params = ifM (Annex.getState Annex.force)
( withFilesInGit a params
, if null params
then giveup needforce
else seekActions $ prepFiltered a (getfiles [] params)
else do
checkFileOrDirectoryExists params
seekActions $ prepFiltered a (getfiles [] params)
)
where
getfiles c [] = return (reverse c)
@ -243,12 +245,15 @@ seekActions gen = mapM_ commandAction =<< gen
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [FilePath] -> Annex [FilePath]
seekHelper a params = do
forM_ params $ \p ->
unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $ do
toplevelWarning False (p ++ " not found")
Annex.incError
checkFileOrDirectoryExists params
inRepo $ \g -> concat . concat <$> forM (segmentXargsOrdered params)
(runSegmentPaths (\fs -> Git.Command.leaveZombie <$> a fs g))
checkFileOrDirectoryExists :: [FilePath] -> Annex ()
checkFileOrDirectoryExists ps = forM_ ps $ \p ->
unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $ do
toplevelWarning False (p ++ " not found")
Annex.incError
notSymlink :: FilePath -> IO Bool
notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f

View file

@ -15,4 +15,4 @@ v5.20150710-g8fd705
We use git-annex for our open-source !FreeSurfer software and find very helpful indeed. Thank you. https://surfer.nmr.mgh.harvard.edu/
> [fixed|done]] --[[Joey]]