summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-06-01 11:40:47 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-06-01 11:40:47 -0400
commit9a9aa7cb83b8338331a1fa61e9b8dd2b21b2c538 (patch)
tree0411d7b1ccfa84f0ee00cdbbdfac0081442bfd25 /CmdLine
parent85e62f678cbd6c69edee9a77cd28160483c9257a (diff)
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.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/Seek.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs
index 0afb0e66a..66cd985f4 100644
--- a/CmdLine/Seek.hs
+++ b/CmdLine/Seek.hs
@@ -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