Don't crash if the database doesn't exist

This commit is contained in:
Jonathan Lamothe 2024-09-10 20:12:46 -04:00
parent 86278db578
commit 233a559aaf

View File

@ -47,6 +47,7 @@ import Lens.Micro ((^.))
import Lens.Micro.Mtl (zoom)
import System.EasyFile
( createDirectoryIfMissing
, doesFileExist
, getAppUserDataDirectory
, (</>)
)
@ -70,7 +71,9 @@ loadDatabase = zoom database $ liftIO
( do
dir <- mkAppDir
let fn = dir </> dbFile
decodeFileStrict fn
doesFileExist fn >>= \case
True -> decodeFileStrict fn
False -> return Nothing
) >>= mapM_ put
fallbackHandler :: BrickEvent ResName () -> EventM ResName AppState ()