@@ -5,6 +5,7 @@ module NixDaemonSpec
5
5
, spec
6
6
) where
7
7
8
+ import Control.Exception (catch , SomeException )
8
9
import Control.Monad (forM_ , unless , void )
9
10
import Control.Monad.Catch (MonadMask )
10
11
import Control.Monad.Conc.Class (MonadConc )
@@ -465,13 +466,17 @@ makeProtoSpec f flavor = around f $ do
465
466
-- clear temp gc roots so the delete works. restarting the nix daemon should also do this...
466
467
storeDir <- getStoreDir
467
468
let tempRootsDir = Data.Text. unpack $ mconcat [ Data.Text.Encoding. decodeUtf8 (unStoreDir storeDir), " /../var/nix/temproots/" ]
468
- tempRootList <-
469
- liftIO
470
- $ System.Directory. listDirectory
471
- tempRootsDir
472
- liftIO $ forM_ tempRootList $ \ entry -> do
473
- System.Directory. removeFile
474
- $ mconcat [ tempRootsDir, " /" , entry ]
469
+ liftIO $ do
470
+ tempRootList <-
471
+ System.Directory. listDirectory tempRootsDir
472
+ forM_ tempRootList $ \ entry -> do
473
+ System.Directory. removeFile
474
+ $ mconcat [ tempRootsDir, " /" , entry ]
475
+ -- for MITM, the temp root will get deleted
476
+ -- by the daemon as our nested client exists
477
+ -- but the listDirectory might still see it
478
+ -- causing TOC/TOU flakiness
479
+ `catch` (\ (_e :: SomeException ) -> pure () )
475
480
476
481
GCResult {.. } <-
477
482
collectGarbage
0 commit comments