From da4b5f623273bdb46d8e59f6d35fa7c236d50484 Mon Sep 17 00:00:00 2001 From: Lia Lenckowski Date: Tue, 25 Jul 2023 21:45:11 +0200 Subject: generate bangs.json when not present --- src/BangState.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/BangState.hs b/src/BangState.hs index 582deca..b091532 100644 --- a/src/BangState.hs +++ b/src/BangState.hs @@ -9,6 +9,7 @@ module BangState ( ) where import Codec.Compression.Brotli (compress) +import Control.Applicative ((<|>)) import Control.Concurrent.STM.TChan import Control.Monad (forever) import Data.Aeson @@ -54,8 +55,8 @@ spawnFileSyncThread s = do atomically $ reserialize s loadOwnBangs :: IO Bangs -loadOwnBangs = eitherDecodeFileStrict "bangs.json" >>= \case - Left e -> error e +loadOwnBangs = eitherDecodeFileStrict "bangs.json" <|> return (Left "") >>= \case + Left e -> return mempty Right b -> return b -- also spawns a thread for disk synchronization -- cgit v1.2.3-70-g09d2