From 2e032a5210d5166a42797ee8f296ec4228d6d838 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 23 Oct 2023 10:08:49 +0200 Subject: add `Git.getRootDir` --- app/History/Cache.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'app/History') diff --git a/app/History/Cache.hs b/app/History/Cache.hs index af40a84..d0473e2 100644 --- a/app/History/Cache.hs +++ b/app/History/Cache.hs @@ -2,17 +2,15 @@ module History.Cache (cached) where import Data.Binary (Binary, decodeFileOrFail, encodeFile) import Data.Text qualified as T -import System.Directory (createDirectoryIfMissing, doesFileExist, getCurrentDirectory) +import Git qualified +import System.Directory (createDirectoryIfMissing, doesFileExist) +import System.FilePath (()) cached :: Binary a => T.Text -> (T.Text -> IO a) -> IO a cached hash func = do - -- FIXME Cache inside Git root - -- - -- The cache location should not be dependant on the current directory, but - -- should be placed alongside the `.git` directory. - cwd <- getCurrentDirectory - createDirectoryIfMissing True (cwd ++ "/.anissue") - let file = (cwd ++ "/.anissue/" ++ T.unpack hash) + root <- Git.getRootDir + createDirectoryIfMissing True (root ".anissue") + let file = (root ".anissue" T.unpack hash) doesFileExist file >>= \case True -> decodeFileOrFail file >>= \case -- cgit v1.2.3