diff options
3 files changed, 21 insertions, 8 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 838b8fd4d..d6a4c6143 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -258,8 +258,7 @@ performQuvi relaxed pageurl videourl file = ifAnnexed file addurl geturl #ifdef WITH_QUVI addUrlFileQuvi :: Bool -> URLString -> URLString -> FilePath -> Annex (Maybe Key) -addUrlFileQuvi relaxed quviurl videourl file = do - checkDoesNotExist file +addUrlFileQuvi relaxed quviurl videourl file = stopUnless (doesNotExist file) $ do let key = Backend.URL.fromUrl quviurl Nothing ifM (pure relaxed <||> Annex.getState Annex.fast) ( do @@ -309,19 +308,20 @@ addUrlChecked relaxed url u checkexistssize key ) addUrlFile :: Bool -> URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key) -addUrlFile relaxed url urlinfo file = do - checkDoesNotExist file +addUrlFile relaxed url urlinfo file = stopUnless (doesNotExist file) $ do liftIO $ createDirectoryIfMissing True (parentDir file) ifM (Annex.getState Annex.fast <||> pure relaxed) ( nodownload url urlinfo file , downloadWeb url urlinfo file ) -checkDoesNotExist :: FilePath -> Annex () -checkDoesNotExist file = go =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus file) +doesNotExist :: FilePath -> Annex Bool +doesNotExist file = go =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus file) where - go Nothing = return () - go (Just _) = error $ file ++ " already exists and is not annexed; not overwriting" + go Nothing = return True + go (Just _) = do + warning $ file ++ " already exists and is not annexed; not overwriting" + return False downloadWeb :: URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key) downloadWeb url urlinfo file = do diff --git a/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists.mdwn b/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists.mdwn index db467055a..c135f7f32 100644 --- a/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists.mdwn +++ b/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists.mdwn @@ -17,3 +17,5 @@ $> echo "http://www.onerussian.com/tmp/banner.png 123" | git annex addurl --batc """]] [[!meta author=yoh]] + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists/comment_2_8f6d5e3b2e37f741bd18044345007cfb._comment b/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists/comment_2_8f6d5e3b2e37f741bd18044345007cfb._comment new file mode 100644 index 000000000..c0561cf77 --- /dev/null +++ b/doc/bugs/addurl_--batch___40__--json_or_not__41___doesn__39__t_report_failure_correctly_if_non-annexed_file_exists/comment_2_8f6d5e3b2e37f741bd18044345007cfb._comment @@ -0,0 +1,11 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 2""" + date="2016-01-15T18:24:28Z" + content=""" +Dude, you're /dev/nulling stderr, where the error is printed. + +In any case, sure, we can make addurl not throw a fatal error in this +particular case. There are of course many other error conditions where it +may still throw a fatal error. +"""]] |