Fix a bug in readArraysUpto
Do not quit when the size read is less than the requested size. Quit only when
the size read is 0, that's the only indication of EOF for streaming devices.
like stding, sockets, pipes etc.
commit3c84a0302925902d03169d4b972c4fc2c26f7ebb
authorHarendra Kumar <harendra.kumar@gmail.com>
dateThu 16 May 2019, 14:19 (7 years ago)
parente9267ab
src/Streamly/FileSystem/File.hs+3−3
@@ -183,10 +183,10 @@ readArraysUpto :: (IsStream t, MonadIO m)
183183readArraysUpto size h = go
184184 where
185185 -- XXX use cons/nil instead
186− go = mkStream $ \_ yld sng _ -> do
186+ go = mkStream $ \_ yld _ stp -> do
187187 arr <- liftIO $ readArrayUpto size h
188− if A.length arr < size
189− then sng arr
188+ if A.length arr == 0
189+ then stp
190190 else yld arr go
191191
192192-- XXX read 'Array a' instead of Word8