diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/History.hs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/app/History.hs b/app/History.hs index 36dc1fc..7ed09bc 100644 --- a/app/History.hs +++ b/app/History.hs @@ -348,21 +348,21 @@ fixTreeGrepper treeGrepperResult = cached :: Binary a => Text -> (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/" ++ unpack hash) - fileExists <- doesFileExist file - if fileExists - then do - result <- decodeFileOrFail file - case result of - Left _ -> do - blob <- func hash - encodeFile file blob - pure blob - Right blob -> - pure blob - else do + doesFileExist file >>= \case + True -> + decodeFileOrFail file >>= \case + Left _ -> generate file + Right blob -> pure blob + False -> generate file + where + generate file = do blob <- func hash encodeFile file blob pure blob |