Skip to content

Commit 47e9174

Browse files
committed
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.
1 parent f0dfc6d commit 47e9174

File tree

1 file changed

+1
-1
lines changed
  • hnix-store-core/src/System/Nix/Internal/Nar

1 file changed

+1
-1
lines changed

hnix-store-core/src/System/Nix/Internal/Nar/Parser.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ consume
421421
consume 0 = pure ""
422422
consume n = do
423423
state0 <- State.get
424-
newBytes <- IO.liftIO $ Bytes.hGetSome (handle state0) (max 0 n)
424+
newBytes <- IO.liftIO $ Bytes.hGet (handle state0) (max 0 n)
425425
when (Bytes.length newBytes < n) $
426426
Fail.fail $
427427
"consume: Not enough bytes in handle. Wanted "

0 commit comments

Comments
 (0)