Don't crash if the database doesn't exist
This commit is contained in:
parent
86278db578
commit
233a559aaf
|
@ -47,6 +47,7 @@ import Lens.Micro ((^.))
|
||||||
import Lens.Micro.Mtl (zoom)
|
import Lens.Micro.Mtl (zoom)
|
||||||
import System.EasyFile
|
import System.EasyFile
|
||||||
( createDirectoryIfMissing
|
( createDirectoryIfMissing
|
||||||
|
, doesFileExist
|
||||||
, getAppUserDataDirectory
|
, getAppUserDataDirectory
|
||||||
, (</>)
|
, (</>)
|
||||||
)
|
)
|
||||||
|
@ -70,7 +71,9 @@ loadDatabase = zoom database $ liftIO
|
||||||
( do
|
( do
|
||||||
dir <- mkAppDir
|
dir <- mkAppDir
|
||||||
let fn = dir </> dbFile
|
let fn = dir </> dbFile
|
||||||
decodeFileStrict fn
|
doesFileExist fn >>= \case
|
||||||
|
True -> decodeFileStrict fn
|
||||||
|
False -> return Nothing
|
||||||
) >>= mapM_ put
|
) >>= mapM_ put
|
||||||
|
|
||||||
fallbackHandler :: BrickEvent ResName () -> EventM ResName AppState ()
|
fallbackHandler :: BrickEvent ResName () -> EventM ResName AppState ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user