From b17e32817596c96955a66738ab272804ba3e5137 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Sep 2022 14:01:43 -0400 Subject: [PATCH] avoid unncessary locking by checkLogFile Like the comment says, this works without locking. It looks like I originally copied another function and forgot to remove the locking. Sponsored-by: Dartmouth College's DANDI project --- Command/Move.hs | 3 +-- Logs/File.hs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Command/Move.hs b/Command/Move.hs index efb02b7c2f..55fed5c372 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -396,8 +396,7 @@ logMove srcuuid destuuid deststartedwithcopy key a = go =<< setup go logf -- Only need to check log when there is a copy. | deststartedwithcopy = do - lck <- fromRepo gitAnnexMoveLock - wasnocopy <- checkLogFile (fromRawFilePath logf) lck + wasnocopy <- checkLogFile (fromRawFilePath logf) (== logline) if wasnocopy then go' logf False diff --git a/Logs/File.hs b/Logs/File.hs index 87e479ae7c..7622399108 100644 --- a/Logs/File.hs +++ b/Logs/File.hs @@ -88,8 +88,8 @@ modifyLogFile f lck modf = withExclusiveLock lck $ do -- action is concurrently modifying the file. It does not lock the file, -- for speed, but instead relies on the fact that a log file usually -- ends in a newline. -checkLogFile :: FilePath -> RawFilePath -> (L.ByteString -> Bool) -> Annex Bool -checkLogFile f lck matchf = withExclusiveLock lck $ bracket setup cleanup go +checkLogFile :: FilePath -> (L.ByteString -> Bool) -> Annex Bool +checkLogFile f matchf = bracket setup cleanup go where setup = liftIO $ tryWhenExists $ openFile f ReadMode cleanup Nothing = noop