]> dgit.raspbian.org Git - git-annex.git/commitdiff
cleanup
authorJoey Hess <joeyh@joeyh.name>
Thu, 11 Jul 2024 11:56:55 +0000 (07:56 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 11 Jul 2024 11:56:55 +0000 (07:56 -0400)
P2P/Http.hs

index c0728fde11f0b9a21ee8474dca725be314e40698..d21f6cb1f62ed8465ee1965ffcc7a991e75ad81b 100644 (file)
@@ -237,24 +237,18 @@ clientGet clientenv ver k cu su bypass af o auth =
                                Header h -> h
                                _ -> error "missing data length header"
                        liftIO $ print ("datalength", dl :: Integer)
-                       b <- S.unSourceT (getResponse respheaders) gatherbytestring
+                       b <- S.unSourceT (getResponse respheaders) gatherByteString
                        liftIO $ print "got it all, writing to file 'got'"
                        L.writeFile "got" b
 
-gatherbytestring :: S.StepT IO B.ByteString -> IO L.ByteString
-gatherbytestring x = do
-       l <- unsafeInterleaveIO $ go x
-       return l
+gatherByteString :: S.StepT IO B.ByteString -> IO L.ByteString
+gatherByteString = unsafeInterleaveIO . go
   where
-       go S.Stop        = return LI.Empty
-       go (S.Error err) = error $ show ("ERROR", err)
-       go (S.Skip s)    = do
-               go s
-       go (S.Effect ms) = do
-               ms >>= go
-       go (S.Yield v s) = do
-               liftIO $ print ("chunk", B.length v)
-               LI.Chunk v <$> unsafeInterleaveIO (go s)
+       go S.Stop = return LI.Empty
+       go (S.Error err) = giveup err
+       go (S.Skip s) = go s
+       go (S.Effect ms) = ms >>= go
+       go (S.Yield v s) = LI.Chunk v <$> unsafeInterleaveIO (go s)
 
 clientGet'
        :: ProtocolVersion