From: Joey Hess Date: Mon, 18 Jul 2022 17:49:17 +0000 (-0400) Subject: minor optimisation X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~72^2~33 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1c40b927aa8e6a4dd97a256d263ac147af771c16;p=git-annex.git minor optimisation Avoid re-writing the file when the journal directory did not exist. --- diff --git a/Annex/Journal.hs b/Annex/Journal.hs index a02eaa3155..2dee2b5ea2 100644 --- a/Annex/Journal.hs +++ b/Annex/Journal.hs @@ -84,13 +84,12 @@ setJournalFile _jl ru file content = withOtherTmp $ \tmp -> do -- journal file is written atomically let jfile = journalFile file let tmpfile = tmp P. jfile - let write = liftIO $ do - withFile (fromRawFilePath tmpfile) WriteMode $ \h -> - writeJournalHandle h content - moveFile tmpfile (jd P. jfile) + liftIO $ withFile (fromRawFilePath tmpfile) WriteMode $ \h -> + writeJournalHandle h content + let mv = liftIO $ moveFile tmpfile (jd P. jfile) -- avoid overhead of creating the journal directory when it already -- exists - write `catchIO` (const (createAnnexDirectory jd >> write)) + mv `catchIO` (const (createAnnexDirectory jd >> mv)) data JournalledContent = NoJournalledContent