fix nested progress meters when using git-annex-shell fallback

Caused an ugly blank line when the first progress meter was not used,
but also it may have confused -J display.
This commit is contained in:
Joey Hess 2018-03-12 19:18:47 -04:00
parent 7bed3927ba
commit b96b845ffd
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 21 additions and 23 deletions

View file

@ -470,14 +470,13 @@ copyFromRemote' forcersync r (State connpool _) key file dest meterupdate
file forwardRetry file forwardRetry
(\p -> copier object dest (combineMeterUpdate p meterupdate) checksuccess) (\p -> copier object dest (combineMeterUpdate p meterupdate) checksuccess)
| Git.repoIsSsh (repo r) = if forcersync | Git.repoIsSsh (repo r) = if forcersync
then unVerified fallback then unVerified $ fallback meterupdate
else P2PHelper.retrieve else P2PHelper.retrieve
(Ssh.runProto r connpool False fallback) (\p -> Ssh.runProto r connpool False (fallback p))
key file dest meterupdate key file dest meterupdate
| otherwise = giveup "copying from non-ssh, non-http remote not supported" | otherwise = giveup "copying from non-ssh, non-http remote not supported"
where where
fallback = metered (Just meterupdate) key (return Nothing) $ \p -> fallback p = feedprogressback $ \p' -> do
feedprogressback $ \p' -> do
oh <- mkOutputHandlerQuiet oh <- mkOutputHandlerQuiet
Ssh.rsyncHelper oh (Just (combineMeterUpdate p' p)) Ssh.rsyncHelper oh (Just (combineMeterUpdate p' p))
=<< Ssh.rsyncParamsRemote False r Download key dest file =<< Ssh.rsyncParamsRemote False r Download key dest file
@ -575,7 +574,7 @@ copyToRemote r (State connpool duc) key file meterupdate
) )
| Git.repoIsSsh (repo r) = commitOnCleanup r $ | Git.repoIsSsh (repo r) = commitOnCleanup r $
P2PHelper.store P2PHelper.store
(Ssh.runProto r connpool False copyremotefallback) (\p -> Ssh.runProto r connpool False (copyremotefallback p))
key file meterupdate key file meterupdate
| otherwise = giveup "copying to non-ssh repo not supported" | otherwise = giveup "copying to non-ssh repo not supported"
@ -602,8 +601,7 @@ copyToRemote r (State connpool duc) key file meterupdate
Annex.Content.getViaTmp verify key Annex.Content.getViaTmp verify key
(\dest -> copier object dest p' (liftIO checksuccessio)) (\dest -> copier object dest p' (liftIO checksuccessio))
) )
copyremotefallback = Annex.Content.sendAnnex key noop $ \object -> copyremotefallback p = Annex.Content.sendAnnex key noop $ \object -> do
metered (Just meterupdate) key (return $ Just object) $ \p -> do
-- This is too broad really, but recvkey normally -- This is too broad really, but recvkey normally
-- verifies content anyway, so avoid complicating -- verifies content anyway, so avoid complicating
-- it with a local sendAnnex check and rollback. -- it with a local sendAnnex check and rollback.

View file

@ -30,17 +30,17 @@ type ProtoConnRunner c = forall a. P2P.Proto a -> ClosableConnection c -> Annex
-- the pool when done. -- the pool when done.
type WithConn a c = (ClosableConnection c -> Annex (ClosableConnection c, a)) -> Annex a type WithConn a c = (ClosableConnection c -> Annex (ClosableConnection c, a)) -> Annex a
store :: ProtoRunner Bool -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool store :: (MeterUpdate -> ProtoRunner Bool) -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
store runner k af p = do store runner k af p = do
let getsrcfile = fmap fst <$> prepSendAnnex k let getsrcfile = fmap fst <$> prepSendAnnex k
metered (Just p) k getsrcfile $ \p' -> metered (Just p) k getsrcfile $ \p' ->
fromMaybe False fromMaybe False
<$> runner (P2P.put k af p') <$> runner p' (P2P.put k af p')
retrieve :: ProtoRunner Bool -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex (Bool, Verification) retrieve :: (MeterUpdate -> ProtoRunner Bool) -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex (Bool, Verification)
retrieve runner k af dest p = unVerified $ retrieve runner k af dest p = unVerified $
metered (Just p) k (return Nothing) $ \p' -> fromMaybe False metered (Just p) k (return Nothing) $ \p' -> fromMaybe False
<$> runner (P2P.get dest k af p') <$> runner p (P2P.get dest k af p')
remove :: ProtoRunner Bool -> Key -> Annex Bool remove :: ProtoRunner Bool -> Key -> Annex Bool
remove runner k = fromMaybe False <$> runner (P2P.remove k) remove runner k = fromMaybe False <$> runner (P2P.remove k)

View file

@ -51,8 +51,8 @@ chainGen addr r u c gc = do
{ uuid = u { uuid = u
, cost = cst , cost = cst
, name = Git.repoDescribe r , name = Git.repoDescribe r
, storeKey = store protorunner , storeKey = store (const protorunner)
, retrieveKeyFile = retrieve protorunner , retrieveKeyFile = retrieve (const protorunner)
, retrieveKeyFileCheap = \_ _ _ -> return False , retrieveKeyFileCheap = \_ _ _ -> return False
, removeKey = remove protorunner , removeKey = remove protorunner
, lockContent = Just $ lock withconn runProtoConn u , lockContent = Just $ lock withconn runProtoConn u