From 59abd787c948ef7a6bda3b62be9024212eb69a46 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 15 Jun 2012 19:17:21 -0400 Subject: can't wait for LinkChanges specifically There is indeed a race waiting for LinkChanges: 1. file annexed, link made 2. link deleted 3. inotify event for link creation runs, but as link is gone, handler is not run --- Assistant/Committer.hs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'Assistant') diff --git a/Assistant/Committer.hs b/Assistant/Committer.hs index 64ea300e2..71152e5e9 100644 --- a/Assistant/Committer.hs +++ b/Assistant/Committer.hs @@ -84,23 +84,20 @@ commitThread st changechan = runEvery (Seconds 1) $ do - for write by some other process. - - When a file is added, Inotify will notice the new symlink. So this waits - - for one new LinkChange to be received per file that's successfully - - added, to ensure that its symlink has been staged before returning. + - for additional Changes to arrive, so that the symlink has hopefully been + - staged before returning. -} handleAdds :: ThreadState -> ChangeChan -> [Change] -> IO () handleAdds st changechan cs | null added = noop | otherwise = do - r <- forM added $ catchBoolIO . runThreadState st . add - let numadded = length $ filter id r - handleAdds st changechan =<< waitforlinkchanges [] numadded + forM_ added $ catchBoolIO . runThreadState st . add + handleAdds st changechan =<< getChanges changechan where added = map changeFile $ filter isPendingAdd cs isPendingAdd (Change { changeType = PendingAddChange }) = True isPendingAdd _ = False - isLinkChange (Change { changeType = LinkChange }) = True - isLinkChange _ = False add file = do showStart "add" file @@ -114,14 +111,6 @@ handleAdds st changechan cs showEndOk return True - waitforlinkchanges c n - | n < 1 = return $ concat c - | otherwise = do - (done, rest) <- partition isLinkChange - <$> getChanges changechan - let n' = (n - length done) - waitforlinkchanges (rest:c) n' - commitStaged :: Annex () commitStaged = do Annex.Queue.flush -- cgit v1.2.3