diff options
Diffstat (limited to 'app/History')
-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 |