From 8431cbe95bf48be964c834ad911ae9aa49bf0d61 Mon Sep 17 00:00:00 2001 From: Dmitry Astapov Date: Sun, 23 Feb 2025 12:55:12 +0000 Subject: [PATCH] run: do not try to cache "top-level" journal more than once --- hledger/Hledger/Cli/Commands/Run.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hledger/Hledger/Cli/Commands/Run.hs b/hledger/Hledger/Cli/Commands/Run.hs index 63842ee8b..000f4f772 100644 --- a/hledger/Hledger/Cli/Commands/Run.hs +++ b/hledger/Hledger/Cli/Commands/Run.hs @@ -137,7 +137,9 @@ defaultJournalKey = "journal specified in args of run" addJournalToCache :: Journal -> String -> IO () addJournalToCache j key = modifyMVar_ journalCache $ \cache -> - return $ Map.insert key j cache + case Map.lookup key cache of + Just _ -> return cache + Nothing -> return $ Map.insert key j cache withJournalCached :: CliOpts -> (Journal -> IO ()) -> IO () withJournalCached cliopts cmd = do