avoid double commits with inotify when direct mode file is created
This commit is contained in:
parent
e872c3f648
commit
8cc27b8afc
2 changed files with 7 additions and 3 deletions
|
@ -69,7 +69,6 @@ watchThread = NamedThread "Watcher" $ do
|
||||||
errhook <- hook onErr
|
errhook <- hook onErr
|
||||||
let hooks = mkWatchHooks
|
let hooks = mkWatchHooks
|
||||||
{ addHook = addhook
|
{ addHook = addhook
|
||||||
, modifyHook = addhook
|
|
||||||
, delHook = delhook
|
, delHook = delhook
|
||||||
, addSymlinkHook = addsymlinkhook
|
, addSymlinkHook = addsymlinkhook
|
||||||
, delDirHook = deldirhook
|
, delDirHook = deldirhook
|
||||||
|
@ -143,10 +142,10 @@ onAddDirect file fs = do
|
||||||
case (v, fs) of
|
case (v, fs) of
|
||||||
(Just key, Just filestatus) ->
|
(Just key, Just filestatus) ->
|
||||||
ifM (liftAnnex $ changedFileStatus key filestatus)
|
ifM (liftAnnex $ changedFileStatus key filestatus)
|
||||||
( noChange
|
( do
|
||||||
, do
|
|
||||||
liftAnnex $ changedDirect key file
|
liftAnnex $ changedDirect key file
|
||||||
pendingAddChange file
|
pendingAddChange file
|
||||||
|
, noChange
|
||||||
)
|
)
|
||||||
_ -> pendingAddChange file
|
_ -> pendingAddChange file
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,13 @@ watchDir dir ignored hooks = do
|
||||||
)
|
)
|
||||||
else maybe (runhook delHook Nothing) handleadd
|
else maybe (runhook delHook Nothing) handleadd
|
||||||
=<< getstatus (eventPath evt)
|
=<< getstatus (eventPath evt)
|
||||||
|
{- Add hooks are run when a file is modified for
|
||||||
|
- compatability with INotify, which calls the add
|
||||||
|
- hook when a file is closed, and so tends to call
|
||||||
|
- both add and modify for file modifications. -}
|
||||||
when (hasflag eventFlagItemModified && not (hasflag eventFlagItemIsDir)) $ do
|
when (hasflag eventFlagItemModified && not (hasflag eventFlagItemIsDir)) $ do
|
||||||
ms <- getstatus $ eventPath evt
|
ms <- getstatus $ eventPath evt
|
||||||
|
maybe noop handleadd ms
|
||||||
runhook modifyHook ms
|
runhook modifyHook ms
|
||||||
where
|
where
|
||||||
hasflag f = eventFlags evt .&. f /= 0
|
hasflag f = eventFlags evt .&. f /= 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue