From 9a9aa7cb83b8338331a1fa61e9b8dd2b21b2c538 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 1 Jun 2017 11:40:47 -0400 Subject: 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. --- CmdLine/Seek.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'CmdLine') 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 -- cgit v1.2.3