From 8d83317251183ee70b1b7c2148c8de12d92f642c Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Sun, 15 Oct 2023 14:09:37 +0300 Subject: [PATCH] fix hbs2-reposync for RO config --- hbs2-git/reposync/ReposyncMain.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hbs2-git/reposync/ReposyncMain.hs b/hbs2-git/reposync/ReposyncMain.hs index e782223f..d6cf5837 100644 --- a/hbs2-git/reposync/ReposyncMain.hs +++ b/hbs2-git/reposync/ReposyncMain.hs @@ -19,8 +19,8 @@ import Data.Config.Suckless.Syntax import Data.Config.Suckless.KeyValue -import Control.Monad.Catch -import Control.Monad.Except +import Control.Monad.Catch (MonadThrow(..)) +import Control.Monad.Except (runExceptT,throwError) import Control.Monad.Reader import Data.ByteString.Lazy.Char8 qualified as LBS import Data.Either @@ -127,9 +127,8 @@ newState so refLog = withConfig :: forall a m . (MonadUnliftIO m) => Maybe FilePath -> ReposyncM m a -> ReposyncM m () withConfig cfg m = do - debug $ "wtf?" - let defDir = reposyncDefaultDir + defConfDir <- liftIO $ getXdgDirectory XdgConfig myName realCfg <- case cfg of @@ -137,9 +136,9 @@ withConfig cfg m = do Nothing -> do liftIO do let conf = defConfDir "config" - createDirectoryIfMissing True defConfDir + void $ try @_ @IOException $ createDirectoryIfMissing True defConfDir debug $ "config-dir" <+> pretty defConfDir - appendFile conf "" + void $ try @_ @IOException $ appendFile conf "" pure conf syn <- liftIO (readFile realCfg) <&> parseTop