@@ -40,26 +40,6 @@ upsertFile
4040upsertFile bucketName pth d mimeType =
4141 send (putObject bucketName (ObjectKey pth) (toBody d) & poContentType ?~ mimeType)
4242
43- data NarInfo
44- = NarInfo Path BS. ByteString BS. ByteString (Digest 'SHA256) Int (Digest 'SHA256) Int Text
45-
46- narInfoToString
47- :: Text
48- -> NarInfo
49- -> BS. ByteString
50- narInfoToString storeDir (NarInfo pth url compression fileHash fileSize narHash' narSize' ca') =
51- BS. unlines
52- [ " StorePath: " <> E. encodeUtf8 (pathToText storeDir pth)
53- , " URL: " <> url
54- , " Compression: " <> compression
55- , " FileHash: " <> E. encodeUtf8 (digestText32 fileHash)
56- , " FileSize: " <> fromString (show fileSize)
57- , " NarHash: " <> E. encodeUtf8 (digestText32 narHash')
58- , " NarSize: " <> fromString (show narSize')
59- , " References: "
60- , " CA: " <> E. encodeUtf8 ca'
61- ]
62-
6343narInfoFileFor
6444 :: Path
6545 -> Text
@@ -97,20 +77,28 @@ addToStore storeDir bucketName name pth recursive pfilter repair = do
9777 let
9878 pth' = makeFixedOutputPath storeDir recursive h . E. decodeUtf8 $ LBS. toStrict name
9979 narCompressed = nar & lazy %~ compress
100- url = " nar/" <> printAsBase32 fileHash <> " .nar.xz"
101- fileHash = hash @ 'SHA256 narCompressed
80+ fileHash' = hash @ 'SHA256 narCompressed
81+ url = " nar/" <> printAsBase32 fileHash' <> " .nar.xz"
82+ validPathInfo =
83+ ValidPathInfo
84+ pth'
85+ Nothing
86+ (digestText32 $ hash @ 'SHA256 nar)
87+ mempty
88+ 0
89+ (fromIntegral $ BS. length nar)
90+ False
91+ []
92+ (makeFixedOutputCA recursive h)
10293 narInfo =
10394 NarInfo
104- pth'
105- (E. encodeUtf8 url)
95+ validPathInfo
96+ url
97+ (digestText32 fileHash')
98+ (fromIntegral $ BS. length narCompressed)
10699 " xz"
107- fileHash
108- (BS. length narCompressed)
109- (hash @ 'SHA256 nar)
110- (BS. length nar)
111- (makeFixedOutputCA recursive h)
112100
113101 void . lift $ upsertFile bucketName url narCompressed " application/x-nix-nar"
114- void . lift $ upsertFile bucketName (narInfoFileFor pth') (narInfoToString storeDir narInfo) " text/x-nix-narinfo"
102+ void . lift $ upsertFile bucketName (narInfoFileFor pth') (E. encodeUtf8 $ narInfoToString storeDir narInfo) " text/x-nix-narinfo"
115103
116104 pure pth'
0 commit comments