Skip to content

Commit 8f2b33e

Browse files
committed
remote: add Types.Query.Missing for QueryMissing result
1 parent d4bfb89 commit 8f2b33e

File tree

7 files changed

+46
-21
lines changed

7 files changed

+46
-21
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ library
8989
, System.Nix.Store.Remote.Types.Handshake
9090
, System.Nix.Store.Remote.Types.Logger
9191
, System.Nix.Store.Remote.Types.ProtoVersion
92+
, System.Nix.Store.Remote.Types.Query
93+
, System.Nix.Store.Remote.Types.Query.Missing
9294
, System.Nix.Store.Remote.Types.StoreConfig
9395
, System.Nix.Store.Remote.Types.StoreRequest
9496
, System.Nix.Store.Remote.Types.StoreText

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,23 +401,18 @@ queryPathFromHashPart storePathHash = do
401401

402402
queryMissing
403403
:: (HashSet StorePath)
404-
-> MonadStore
405-
( HashSet StorePath -- Paths that will be built
406-
, HashSet StorePath -- Paths that have substitutes
407-
, HashSet StorePath -- Unknown paths
408-
, Integer -- Download size
409-
, Integer -- Nar size?
410-
)
404+
-> MonadStore Missing
411405
queryMissing ps = do
412406
storeDir <- getStoreDir
413407
runOpArgs WorkerOp_QueryMissing $ putPaths storeDir ps
414408

415-
willBuild <- sockGetPaths
416-
willSubstitute <- sockGetPaths
417-
unknown <- sockGetPaths
418-
downloadSize' <- sockGetInt
419-
narSize' <- sockGetInt
420-
pure (willBuild, willSubstitute, unknown, downloadSize', narSize')
409+
missingWillBuild <- sockGetPaths
410+
missingWillSubstitute <- sockGetPaths
411+
missingUnknownPaths <- sockGetPaths
412+
missingDownloadSize <- sockGetInt
413+
missingNarSize <- sockGetInt
414+
415+
pure Missing{..}
421416

422417
optimiseStore :: MonadStore ()
423418
optimiseStore = Control.Monad.void $ simpleOp WorkerOp_OptimiseStore

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module System.Nix.Store.Remote.Types
44
, module System.Nix.Store.Remote.Types.CheckMode
55
, module System.Nix.Store.Remote.Types.Logger
66
, module System.Nix.Store.Remote.Types.ProtoVersion
7+
, module System.Nix.Store.Remote.Types.Query
78
, module System.Nix.Store.Remote.Types.StoreConfig
89
, module System.Nix.Store.Remote.Types.StoreRequest
910
, module System.Nix.Store.Remote.Types.StoreText
@@ -19,6 +20,7 @@ import System.Nix.Store.Remote.Types.GC
1920
import System.Nix.Store.Remote.Types.CheckMode
2021
import System.Nix.Store.Remote.Types.Logger
2122
import System.Nix.Store.Remote.Types.ProtoVersion
23+
import System.Nix.Store.Remote.Types.Query
2224
import System.Nix.Store.Remote.Types.StoreConfig
2325
import System.Nix.Store.Remote.Types.StoreRequest
2426
import System.Nix.Store.Remote.Types.StoreText
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module System.Nix.Store.Remote.Types.Query
2+
( module System.Nix.Store.Remote.Types.Query.Missing
3+
) where
4+
5+
import System.Nix.Store.Remote.Types.Query.Missing
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module System.Nix.Store.Remote.Types.Query.Missing
2+
( Missing(..)
3+
) where
4+
5+
import Data.HashSet (HashSet)
6+
import Data.Word (Word64)
7+
import GHC.Generics (Generic)
8+
import System.Nix.StorePath (StorePath)
9+
10+
-- | Result of @QueryMissing@ @StoreRequest@
11+
data Missing = Missing
12+
{ missingWillBuild :: HashSet StorePath -- ^ Paths that will be built
13+
, missingWillSubstitute :: HashSet StorePath -- ^ Paths that can be substituted from cache
14+
, missingUnknownPaths :: HashSet StorePath -- ^ Path w/o any information
15+
, missingDownloadSize :: Word64 -- ^ Total size of packed NARs to download
16+
, missingNarSize :: Word64 -- ^ Total size of NARs after unpacking
17+
}
18+
deriving (Eq, Generic, Ord, Show)

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import System.Nix.Store.Types (FileIngestionMethod, RepairMode)
2424
import System.Nix.StorePath (StorePath, StorePathName, StorePathHashPart)
2525
import System.Nix.StorePath.Metadata (Metadata)
2626
import System.Nix.Store.Remote.Types.CheckMode (CheckMode)
27+
import System.Nix.Store.Remote.Types.Query.Missing (Missing)
2728
import System.Nix.Store.Remote.Types.StoreText (StoreText)
2829
import System.Nix.Store.Remote.Types.SubstituteMode (SubstituteMode)
2930

@@ -138,13 +139,7 @@ data StoreRequest :: Type -> Type where
138139

139140
QueryMissing
140141
:: Set DerivedPath
141-
-> StoreRequest
142-
( HashSet StorePath -- Paths that will be built
143-
, HashSet StorePath -- Paths that have substitutes
144-
, HashSet StorePath -- Unknown paths
145-
, Integer -- Download size
146-
, Integer -- Nar size?
147-
)
142+
-> StoreRequest Missing
148143

149144
OptimiseStore
150145
:: StoreRequest ()

hnix-store-remote/tests-io/NixDaemon.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,15 @@ spec_protocol = Hspec.around withNixDaemon $
262262
context "queryMissing" $
263263
itRights "queries" $ withPath $ \path -> do
264264
let pathSet = HS.fromList [path]
265-
queryMissing pathSet `shouldReturn` (HS.empty, HS.empty, HS.empty, 0, 0)
265+
queryMissing pathSet
266+
`shouldReturn`
267+
Missing
268+
{ missingWillBuild = mempty
269+
, missingWillSubstitute = mempty
270+
, missingUnknownPaths = mempty
271+
, missingDownloadSize = 0
272+
, missingNarSize = 0
273+
}
266274

267275
context "addToStore" $
268276
itRights "adds file to store" $ do

0 commit comments

Comments
 (0)