Fix NAR parsing failure when not enough input is available

Replaces `hGetSome` with `hGet`, which should continue reading until the
requested number of bytes have been read in. This avoids a potential
failure mode where the requested bytes are not immediately
available/buffered.

Resolves #225.
This commit is contained in:
Sander 2023-11-09 19:19:33 +00:00
parent f0dfc6d670
commit 47e9174d08
No known key found for this signature in database
GPG Key ID: D1A763BC84F34603

View File

@ -421,7 +421,7 @@ consume
consume 0 = pure ""
consume n = do
state0 <- State.get
newBytes <- IO.liftIO $ Bytes.hGetSome (handle state0) (max 0 n)
newBytes <- IO.liftIO $ Bytes.hGet (handle state0) (max 0 n)
when (Bytes.length newBytes < n) $
Fail.fail $
"consume: Not enough bytes in handle. Wanted "