aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/History.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/History.hs b/app/History.hs
index b6cef76..a12ea6e 100644
--- a/app/History.hs
+++ b/app/History.hs
@@ -6,7 +6,7 @@ module History (getIssues, listIssues) where
import Control.Exception (Exception, catch, handle, throw)
import Data.Aeson (eitherDecode)
-import Data.Binary (Binary, decodeFile, encodeFile)
+import Data.Binary (Binary, decodeFileOrFail, encodeFile)
import Data.ByteString.Lazy.Char8 qualified as L8
import Data.Function ((&))
import Data.List (foldl', intercalate)
@@ -342,7 +342,15 @@ cached hash func = do
let file = (cwd ++ "/.anissue/" ++ unpack hash)
fileExists <- doesFileExist file
if fileExists
- then decodeFile file
+ then do
+ result <- decodeFileOrFail file
+ case result of
+ Left _ -> do
+ blob <- func hash
+ encodeFile file blob
+ pure blob
+ Right blob ->
+ pure blob
else do
blob <- func hash
encodeFile file blob