diff --git a/src/Password/App/Event.hs b/src/Password/App/Event.hs index 65d2869..b8f7cbc 100644 --- a/src/Password/App/Event.hs +++ b/src/Password/App/Event.hs @@ -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 ()