record initial seed in sim log
authorJoey Hess <joeyh@joeyh.name>
Tue, 17 Sep 2024 17:49:50 +0000 (13:49 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 17 Sep 2024 17:49:50 +0000 (13:49 -0400)
Unless the log starts with a command that records a seed.

Annex/Sim.hs
Command/Sim.hs

index ecbdfbafa0c9c803158465e4af229b4f9aa6ab1a..8bf8b71056ba468a869c1c464d0d7b7e920628fb 100644 (file)
@@ -145,6 +145,10 @@ getSimLocations' = M.keysSet . M.filter present
 addHistory :: SimState t -> SimCommand -> SimState t
 addHistory st c = st { simHistory = c : simHistory st }
 
+recordSeed :: SimState t -> [SimCommand] -> SimState t
+recordSeed st (CommandSeed _:_) = st
+recordSeed st _ = addHistory st (CommandSeed (simRng st))
+
 newtype RepoName = RepoName { fromRepoName :: String }
        deriving (Show, Read, Eq, Ord)
 
index a4eef730d9a6cf3ddb8806fa5297edde9b0efb68..93ea3d3d931edee4c60fe6ddc0fd20509046b552 100644 (file)
@@ -94,8 +94,9 @@ start simfile = do
        startup simdir st cs = do
                repobyname <- mkGetExistingRepoByName
                createAnnexDirectory (toRawFilePath simdir)
-               st' <- go st repobyname cs
-               liftIO $ saveState st'
+               let st' = recordSeed st cs
+               st'' <- go st' repobyname cs
+               liftIO $ saveState st''
 
        go st _ [] = return st
        go st repobyname (c:cs) = do