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
This commit is contained in:
parent
ed8afacc39
commit
b17e328175
2 changed files with 3 additions and 4 deletions
|
@ -396,8 +396,7 @@ logMove srcuuid destuuid deststartedwithcopy key a = go =<< setup
|
||||||
go logf
|
go logf
|
||||||
-- Only need to check log when there is a copy.
|
-- Only need to check log when there is a copy.
|
||||||
| deststartedwithcopy = do
|
| deststartedwithcopy = do
|
||||||
lck <- fromRepo gitAnnexMoveLock
|
wasnocopy <- checkLogFile (fromRawFilePath logf)
|
||||||
wasnocopy <- checkLogFile (fromRawFilePath logf) lck
|
|
||||||
(== logline)
|
(== logline)
|
||||||
if wasnocopy
|
if wasnocopy
|
||||||
then go' logf False
|
then go' logf False
|
||||||
|
|
|
@ -88,8 +88,8 @@ modifyLogFile f lck modf = withExclusiveLock lck $ do
|
||||||
-- action is concurrently modifying the file. It does not lock the file,
|
-- 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
|
-- for speed, but instead relies on the fact that a log file usually
|
||||||
-- ends in a newline.
|
-- ends in a newline.
|
||||||
checkLogFile :: FilePath -> RawFilePath -> (L.ByteString -> Bool) -> Annex Bool
|
checkLogFile :: FilePath -> (L.ByteString -> Bool) -> Annex Bool
|
||||||
checkLogFile f lck matchf = withExclusiveLock lck $ bracket setup cleanup go
|
checkLogFile f matchf = bracket setup cleanup go
|
||||||
where
|
where
|
||||||
setup = liftIO $ tryWhenExists $ openFile f ReadMode
|
setup = liftIO $ tryWhenExists $ openFile f ReadMode
|
||||||
cleanup Nothing = noop
|
cleanup Nothing = noop
|
||||||
|
|
Loading…
Reference in a new issue