diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-12-02 15:34:15 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-12-02 15:39:49 -0400 |
commit | 956d94aca4305d6f957fb4520f059259a2e7bfdb (patch) | |
tree | a9dd761624ac7debe647305bf4755a9cadb993c0 /P2P/Annex.hs | |
parent | 98838a112219dbf57d5ef3a101122cde180faf9f (diff) |
plumb peer uuid through to runLocal
This will allow updating transfer logs with the uuid.
Diffstat (limited to 'P2P/Annex.hs')
-rw-r--r-- | P2P/Annex.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/P2P/Annex.hs b/P2P/Annex.hs index d9ea530f0..dce4ceeba 100644 --- a/P2P/Annex.hs +++ b/P2P/Annex.hs @@ -8,7 +8,8 @@ {-# LANGUAGE RankNTypes, FlexibleContexts #-} module P2P.Annex - ( RunEnv(..) + ( RunMode(..) + , RunEnv(..) , runFullProto ) where @@ -22,17 +23,23 @@ import Types.NumCopies import Control.Monad.Free import qualified Data.ByteString.Lazy as L +-- When we're serving a peer, we know their uuid, and can use it to update +-- transfer logs. +data RunMode + = Serving UUID + | Client + -- Full interpreter for Proto, that can receive and send objects. -runFullProto :: RunEnv -> Proto a -> Annex (Maybe a) -runFullProto runenv = go +runFullProto :: RunMode -> RunEnv -> Proto a -> Annex (Maybe a) +runFullProto runmode runenv = go where go :: RunProto Annex go (Pure v) = pure (Just v) go (Free (Net n)) = runNet runenv go n - go (Free (Local l)) = runLocal go l + go (Free (Local l)) = runLocal runmode go l -runLocal :: RunProto Annex -> LocalF (Proto a) -> Annex (Maybe a) -runLocal runner a = case a of +runLocal :: RunMode -> RunProto Annex -> LocalF (Proto a) -> Annex (Maybe a) +runLocal runmode runner a = case a of TmpContentSize k next -> do tmp <- fromRepo $ gitAnnexTmpObjectLocation k size <- liftIO $ catchDefaultIO 0 $ getFileSize tmp |