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
This commit is contained in:
parent
679ef4c858
commit
59abd787c9
1 changed files with 4 additions and 15 deletions
|
@ -84,23 +84,20 @@ commitThread st changechan = runEvery (Seconds 1) $ do
|
||||||
- for write by some other process.
|
- for write by some other process.
|
||||||
-
|
-
|
||||||
- When a file is added, Inotify will notice the new symlink. So this waits
|
- 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
|
- for additional Changes to arrive, so that the symlink has hopefully been
|
||||||
- added, to ensure that its symlink has been staged before returning.
|
- staged before returning.
|
||||||
-}
|
-}
|
||||||
handleAdds :: ThreadState -> ChangeChan -> [Change] -> IO ()
|
handleAdds :: ThreadState -> ChangeChan -> [Change] -> IO ()
|
||||||
handleAdds st changechan cs
|
handleAdds st changechan cs
|
||||||
| null added = noop
|
| null added = noop
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
r <- forM added $ catchBoolIO . runThreadState st . add
|
forM_ added $ catchBoolIO . runThreadState st . add
|
||||||
let numadded = length $ filter id r
|
handleAdds st changechan =<< getChanges changechan
|
||||||
handleAdds st changechan =<< waitforlinkchanges [] numadded
|
|
||||||
where
|
where
|
||||||
added = map changeFile $ filter isPendingAdd cs
|
added = map changeFile $ filter isPendingAdd cs
|
||||||
|
|
||||||
isPendingAdd (Change { changeType = PendingAddChange }) = True
|
isPendingAdd (Change { changeType = PendingAddChange }) = True
|
||||||
isPendingAdd _ = False
|
isPendingAdd _ = False
|
||||||
isLinkChange (Change { changeType = LinkChange }) = True
|
|
||||||
isLinkChange _ = False
|
|
||||||
|
|
||||||
add file = do
|
add file = do
|
||||||
showStart "add" file
|
showStart "add" file
|
||||||
|
@ -114,14 +111,6 @@ handleAdds st changechan cs
|
||||||
showEndOk
|
showEndOk
|
||||||
return True
|
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 :: Annex ()
|
||||||
commitStaged = do
|
commitStaged = do
|
||||||
Annex.Queue.flush
|
Annex.Queue.flush
|
||||||
|
|
Loading…
Reference in a new issue