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 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 ()
|
||||
|
|
Loading…
Reference in New Issue
Block a user