sim: quiesce before freezing or ending

Probably a good idea for freezing, but especially I hope this fixes a
problem with git-annex sim run that caused it to sometimes crash in
removeDirectoryRecursive with directory not empty, presumably because a
thread was writing there at the same time.
This commit is contained in:
Joey Hess 2024-09-24 16:46:09 -04:00
parent 540bd5e1ab
commit 8047128591
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 23 additions and 7 deletions

View file

@ -33,9 +33,10 @@ seek ("show":[]) = do
seek ("run":simfile:[]) = startsim' (Just simfile) >>= cleanup
where
cleanup st = do
st' <- liftIO $ quiesceSim st
endsim
when (simFailed st) $ do
showsim st
when (simFailed st') $ do
showsim st'
giveup "Simulation shown above had errors."
seek ps = case parseSimCommand ps of
Left err -> giveup err