record initial seed in sim log

Unless the log starts with a command that records a seed.
This commit is contained in:
Joey Hess 2024-09-17 13:49:50 -04:00
parent 02f0996e25
commit e568ac96b7
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 7 additions and 2 deletions

View 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)

View 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