@@ -41,13 +41,13 @@ upsertFile bucketName pth d mimeType =
4141 send (putObject bucketName (ObjectKey pth) (toBody d) & poContentType ?~ mimeType)
4242
4343data NarInfo
44- = NarInfo Path BS. ByteString BS. ByteString (Digest 'SHA256) Int (Digest 'SHA256) Int
44+ = NarInfo Path BS. ByteString BS. ByteString (Digest 'SHA256) Int (Digest 'SHA256) Int Text
4545
4646narInfoToString
4747 :: Text
4848 -> NarInfo
4949 -> BS. ByteString
50- narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash' narSize') =
50+ narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash' narSize' ca' ) =
5151 BS. unlines
5252 [ " StorePath: " <> E. encodeUtf8 (pathToText storeDir pth)
5353 , " URL: " <> url
@@ -57,14 +57,14 @@ narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash'
5757 , " NarHash: " <> E. encodeUtf8 (digestText32 narHash')
5858 , " NarSize: " <> fromString (show narSize')
5959 , " References: "
60+ , " CA: " <> E. encodeUtf8 ca'
6061 ]
6162
6263narInfoFileFor
63- :: Text
64- -> Path
64+ :: Path
6565 -> Text
66- narInfoFileFor storeDir pth =
67- pathToText storeDir pth <> " .narinfo"
66+ narInfoFileFor ( Path h _) =
67+ printAsBase32 h <> " .narinfo"
6868
6969addToStore
7070 :: Text
@@ -99,9 +99,18 @@ addToStore storeDir bucketName name pth recursive pfilter repair = do
9999 narCompressed = nar & lazy %~ compress
100100 url = " nar/" <> printAsBase32 fileHash <> " .nar.xz"
101101 fileHash = hash @ 'SHA256 narCompressed
102- narInfo = NarInfo pth' (E. encodeUtf8 url) " xz" fileHash (BS. length narCompressed) (hash @ 'SHA256 nar) (BS. length nar)
102+ narInfo =
103+ NarInfo
104+ pth'
105+ (E. encodeUtf8 url)
106+ " xz"
107+ fileHash
108+ (BS. length narCompressed)
109+ (hash @ 'SHA256 nar)
110+ (BS. length nar)
111+ (makeFixedOutputCA recursive h)
103112
104113 void . lift $ upsertFile bucketName url narCompressed " application/x-nix-nar"
105- void . lift $ upsertFile bucketName (narInfoFileFor storeDir pth') (narInfoToString storeDir narInfo) " text/x-nix-narinfo"
114+ void . lift $ upsertFile bucketName (narInfoFileFor pth') (narInfoToString storeDir narInfo) " text/x-nix-narinfo"
106115
107116 pure pth'
0 commit comments