From 2cbd3fb26bf1aee5c45998f074a348fa6103aa90 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 12 Sep 2024 16:39:44 -0400 Subject: [PATCH] sim command fixes --- Command/Sim.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Command/Sim.hs b/Command/Sim.hs index 76dd88af3b..a3e096ceff 100644 --- a/Command/Sim.hs +++ b/Command/Sim.hs @@ -27,8 +27,9 @@ seek :: CmdParams -> CommandSeek seek ("start":[]) = start Nothing seek ("start":simfile:[]) = start (Just simfile) seek ("end":[]) = do - simdir <- fromRepo gitAnnexSimDir - liftIO $ removeDirectoryRecursive $ fromRawFilePath simdir + simdir <- fromRawFilePath <$> fromRepo gitAnnexSimDir + whenM (liftIO $ doesDirectoryExist simdir) $ do + liftIO $ removeDirectoryRecursive simdir seek ("visit":reponame:[]) = do simdir <- fromRepo gitAnnexSimDir liftIO (restoreSim simdir) >>= \case @@ -76,9 +77,10 @@ start simfile = do { simFile = Just simlogfile } case simfile of Nothing -> startup simdir st [] - Just f -> case parseSimFile f of - Left err -> giveup err - Right cs -> startup simdir st cs + Just f -> liftIO (readFile f) >>= \c -> + case parseSimFile c of + Left err -> giveup err + Right cs -> startup simdir st cs showLongNote $ UnquotedString "Sim started, logging to sim file " <> QuotedPath (toRawFilePath simlogfile) where