From e568ac96b7cba66b31aabbe87400a53faf34165f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 17 Sep 2024 13:49:50 -0400 Subject: [PATCH] record initial seed in sim log Unless the log starts with a command that records a seed. --- Annex/Sim.hs | 4 ++++ Command/Sim.hs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Annex/Sim.hs b/Annex/Sim.hs index ecbdfbafa0..8bf8b71056 100644 --- a/Annex/Sim.hs +++ b/Annex/Sim.hs @@ -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) diff --git a/Command/Sim.hs b/Command/Sim.hs index a4eef730d9..93ea3d3d93 100644 --- a/Command/Sim.hs +++ b/Command/Sim.hs @@ -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