From 9f3a346f25b87bbad3feb0331f0f72fe9d830c9a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 3 Jul 2018 13:09:04 -0400 Subject: [PATCH] fix nested exception bug Fix reversion introduced in version 6.20180316 that caused git-annex to stop processing files when unable to contact a ssh remote. The bug was not in any of the changed lines, but this one in inAnnex: P2PHelper.checkpresent (Ssh.runProto rmt connpool (cantCheck rmt) fallback) key cantCheck throws an exception, but that parameter to runProto expects a value, which it returns. So, inAnnex is returning a Bool containing an exception. This defeats the usual checks for checkPresent throwing an exception, crashing git-annex. Fixed by making runProto take an `Annex a` instead of an `a`, so passing cantCheck to it doesn't nest exceptions. This commit was sponsored by andrea rota. --- CHANGELOG | 2 ++ Remote/Git.hs | 6 +++--- Remote/Helper/Ssh.hs | 6 +++--- ...omment_1_dbca6ea763702a82ae7563722cdc7fab._comment | 11 +++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 doc/forum/sync_quits_after_first_non-successfull_remote/comment_1_dbca6ea763702a82ae7563722cdc7fab._comment diff --git a/CHANGELOG b/CHANGELOG index 0f826daef7..7b75b59de9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,8 @@ git-annex (6.20180627) UNRELEASED; urgency=medium still check if the url is one that it supports, and fail downloading it, instead of downloading the raw web page. * git-annex.cabal: Fix network version. + * Fix reversion introduced in version 6.20180316 that caused git-annex to + stop processing files when unable to contact a ssh remote. -- Joey Hess Fri, 22 Jun 2018 10:36:22 -0400 diff --git a/Remote/Git.hs b/Remote/Git.hs index 8a2ee9acaa..fd8c05b3c9 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -395,7 +395,7 @@ dropKey' repo r (State connpool duc _) key | Git.repoIsHttp repo = giveup "dropping from http remote not supported" | otherwise = commitOnCleanup repo r $ do let fallback = Ssh.dropKey repo key - P2PHelper.remove (Ssh.runProto r connpool False fallback) key + P2PHelper.remove (Ssh.runProto r connpool (return False) fallback) key lockKey :: Remote -> State -> Key -> (VerifiedCopy -> Annex r) -> Annex r lockKey r st key callback = do @@ -493,7 +493,7 @@ copyFromRemote'' repo forcersync r (State connpool _ _) key file dest meterupdat | Git.repoIsSsh repo = if forcersync then fallback meterupdate else P2PHelper.retrieve - (\p -> Ssh.runProto r connpool (False, UnVerified) (fallback p)) + (\p -> Ssh.runProto r connpool (return (False, UnVerified)) (fallback p)) key file dest meterupdate | otherwise = giveup "copying from non-ssh, non-http remote not supported" where @@ -605,7 +605,7 @@ copyToRemote' repo r (State connpool duc _) key file meterupdate ) | Git.repoIsSsh repo = commitOnCleanup repo r $ P2PHelper.store - (\p -> Ssh.runProto r connpool False (copyremotefallback p)) + (\p -> Ssh.runProto r connpool (return False) (copyremotefallback p)) key file meterupdate | otherwise = giveup "copying to non-ssh repo not supported" diff --git a/Remote/Helper/Ssh.hs b/Remote/Helper/Ssh.hs index 021e6a087c..2e14472dcc 100644 --- a/Remote/Helper/Ssh.hs +++ b/Remote/Helper/Ssh.hs @@ -321,8 +321,8 @@ newStderrHandler errh = do -- Runs a P2P Proto action on a remote when it supports that, -- otherwise the fallback action. -runProto :: Remote -> P2PSshConnectionPool -> a -> Annex a -> P2P.Proto a -> Annex (Maybe a) -runProto r connpool bad fallback proto = Just <$> +runProto :: Remote -> P2PSshConnectionPool -> Annex a -> Annex a -> P2P.Proto a -> Annex (Maybe a) +runProto r connpool badproto fallback proto = Just <$> (getP2PSshConnection r connpool >>= maybe fallback go) where go c = do @@ -333,7 +333,7 @@ runProto r connpool bad fallback proto = Just <$> return res -- Running the proto failed, either due to a protocol -- error or a network error. - Nothing -> return bad + Nothing -> badproto runProtoConn :: P2P.Proto a -> P2PSshConnection -> Annex (P2PSshConnection, Maybe a) runProtoConn _ P2P.ClosedConnection = return (P2P.ClosedConnection, Nothing) diff --git a/doc/forum/sync_quits_after_first_non-successfull_remote/comment_1_dbca6ea763702a82ae7563722cdc7fab._comment b/doc/forum/sync_quits_after_first_non-successfull_remote/comment_1_dbca6ea763702a82ae7563722cdc7fab._comment new file mode 100644 index 0000000000..e890b13b14 --- /dev/null +++ b/doc/forum/sync_quits_after_first_non-successfull_remote/comment_1_dbca6ea763702a82ae7563722cdc7fab._comment @@ -0,0 +1,11 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2018-07-03T17:00:26Z" + content=""" +Thanks for reporting, I've reproduced and fixed the bug. + +Please file bugs in the bug tracker in the future, +that will prevent me missing them or responding as slowly as I did with +this one. +"""]]