Startup: If repo dir check fails, print both versions of repo tree

This commit is contained in:
fr33domlover 2020-05-14 12:11:31 +00:00
parent cac4edc8eb
commit 2063c7313b

View file

@ -32,6 +32,7 @@ where
import Control.Concurrent.Chan
import Control.Concurrent.STM.TVar
import Control.Exception hiding (Handler)
import Control.Monad
import Control.Monad.Logger (liftLoc, runLoggingT, logInfo, logError)
import Control.Monad.Trans.Reader
@ -229,14 +230,19 @@ makeFoundation appSettings = do
verifyRepoDir = do
repos <- lift repoTreeFromDir
repos' <- repoTreeFromDB
unless (repos == repos') $
error "Repo dir check failed!"
liftIO $
for_ repos $ \ (shr, rps) ->
for_ rps $ \ (rp, vcs) ->
putStrLn $
"Found repo " ++
shr ++ " / " ++ rp ++ " [" ++ show vcs ++ "]"
unless (repos == repos') $ liftIO $ do
putStrLn "Repo tree based on filesystem:"
printRepos repos
putStrLn "Repo tree based on database:"
printRepos repos'
throwIO $ userError "Repo dir check failed!"
liftIO $ printRepos repos
where
printRepos = traverse_ $ \ (shr, rps) ->
for_ rps $ \ (rp, vcs) ->
putStrLn $
"Found repo " ++
shr ++ " / " ++ rp ++ " [" ++ show vcs ++ "]"
repoTreeFromDir = do
dir <- askRepoRootDir
outers <- liftIO $ listDirectory dir