diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-10-23 10:08:49 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-11-07 09:50:52 +0100 |
commit | 2e032a5210d5166a42797ee8f296ec4228d6d838 (patch) | |
tree | bb71d1b466581114ffd7613d950533ffc1298834 /app/History/Cache.hs | |
parent | 1127c71fa5f5c5a3d6bfde818cb00eb26e9d4cb3 (diff) |
add `Git.getRootDir`
Diffstat (limited to 'app/History/Cache.hs')
-rw-r--r-- | app/History/Cache.hs | 14 |
1 files changed, 6 insertions, 8 deletions
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 |