Skip to content

Commit a534259

Browse files
committed
fixup! fixup! fixup! simple store path root, remote store rework
1 parent 1bcd865 commit a534259

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

hnix-store-remote/hnix-store-remote.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ library
2222
, System.Nix.Store.Remote.Util
2323

2424
build-depends: base >=4.10 && <5
25-
, cryptonite
2625
, bytestring
2726
, binary
2827
, bytestring

hnix-store-remote/src/System/Nix/Store/Remote/Binary.hs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ putInt = putWord64le . fromIntegral
1616
getInt :: Integral a => Get a
1717
getInt = fromIntegral <$> getWord64le
1818

19+
putMany :: Foldable t => (a -> Put) -> t a -> Put
20+
putMany printer xs = do
21+
putInt (length xs)
22+
mapM_ printer xs
23+
24+
getMany :: Get a -> Get [a]
25+
getMany parser = do
26+
count <- getInt
27+
replicateM count parser
28+
1929
-- length prefixed string packing with padding to 8 bytes
2030
putByteStringLen :: BSL.ByteString -> Put
2131
putByteStringLen x = do
@@ -29,9 +39,7 @@ putByteStringLen x = do
2939
pad count = sequence_ $ replicate count (putWord8 0)
3040

3141
putByteStrings :: Foldable t => t BSL.ByteString -> Put
32-
putByteStrings xs = do
33-
putInt $ length xs
34-
mapM_ putByteStringLen xs
42+
putByteStrings = putMany putByteStringLen
3543

3644
getByteStringLen :: Get ByteString
3745
getByteStringLen = do
@@ -44,8 +52,4 @@ getByteStringLen = do
4452
where unpad x = sequence $ replicate x getWord8
4553

4654
getByteStrings :: Get [ByteString]
47-
getByteStrings = do
48-
count <- getInt
49-
res <- sequence $ replicate count getByteStringLen
50-
return res
51-
55+
getByteStrings = getMany getByteStringLen

hnix-store-remote/src/System/Nix/Store/Remote/Util.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ putTime = (putInt :: Int -> Put) . round . utcTimeToPOSIXSeconds
132132
getTime :: Get UTCTime
133133
getTime = posixSecondsToUTCTime <$> getEnum
134134

135-
getMany :: Get a -> Get [a]
136-
getMany parser = do
137-
count <- getInt
138-
replicateM count parser
139-
140135
getBuildResult :: Get BuildResult
141136
getBuildResult = BuildResult
142137
<$> getEnum

0 commit comments

Comments
 (0)