assistant adding of modified files in direct mode
Works with inotify, but I think in kqueue we don't get events existing files that get modified.
This commit is contained in:
parent
95db595e91
commit
cc5140d295
2 changed files with 10 additions and 5 deletions
|
@ -147,7 +147,10 @@ delayaddDefault = Nothing
|
||||||
handleAdds :: Maybe Seconds -> [Change] -> Assistant [Change]
|
handleAdds :: Maybe Seconds -> [Change] -> Assistant [Change]
|
||||||
handleAdds delayadd cs = returnWhen (null incomplete) $ do
|
handleAdds delayadd cs = returnWhen (null incomplete) $ do
|
||||||
let (pending, inprocess) = partition isPendingAddChange incomplete
|
let (pending, inprocess) = partition isPendingAddChange incomplete
|
||||||
pending' <- findnew pending
|
direct <- liftAnnex isDirect
|
||||||
|
pending' <- if direct
|
||||||
|
then return pending
|
||||||
|
else findnew pending
|
||||||
(postponed, toadd) <- partitionEithers <$> safeToAdd delayadd pending' inprocess
|
(postponed, toadd) <- partitionEithers <$> safeToAdd delayadd pending' inprocess
|
||||||
|
|
||||||
unless (null postponed) $
|
unless (null postponed) $
|
||||||
|
@ -155,7 +158,6 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
|
||||||
|
|
||||||
returnWhen (null toadd) $ do
|
returnWhen (null toadd) $ do
|
||||||
added <- catMaybes <$> forM toadd add
|
added <- catMaybes <$> forM toadd add
|
||||||
direct <- liftAnnex isDirect
|
|
||||||
if DirWatcher.eventsCoalesce || null added || direct
|
if DirWatcher.eventsCoalesce || null added || direct
|
||||||
then return $ added ++ otherchanges
|
then return $ added ++ otherchanges
|
||||||
else do
|
else do
|
||||||
|
|
|
@ -35,6 +35,7 @@ import qualified Backend
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
import Git.Types
|
import Git.Types
|
||||||
|
import Config
|
||||||
|
|
||||||
import Data.Bits.Utils
|
import Data.Bits.Utils
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
|
@ -58,7 +59,8 @@ needLsof = error $ unlines
|
||||||
watchThread :: NamedThread
|
watchThread :: NamedThread
|
||||||
watchThread = NamedThread "Watcher" $ do
|
watchThread = NamedThread "Watcher" $ do
|
||||||
startup <- asIO1 startupScan
|
startup <- asIO1 startupScan
|
||||||
addhook <- hook onAdd
|
direct <- liftAnnex isDirect
|
||||||
|
addhook <- hook $ onAdd direct
|
||||||
delhook <- hook onDel
|
delhook <- hook onDel
|
||||||
addsymlinkhook <- hook onAddSymlink
|
addsymlinkhook <- hook onAddSymlink
|
||||||
deldirhook <- hook onDelDir
|
deldirhook <- hook onDelDir
|
||||||
|
@ -124,8 +126,9 @@ runHandler handler file filestatus = void $ do
|
||||||
liftAnnex $ Annex.Queue.flushWhenFull
|
liftAnnex $ Annex.Queue.flushWhenFull
|
||||||
recordChange change
|
recordChange change
|
||||||
|
|
||||||
onAdd :: Handler
|
onAdd :: Bool -> Handler
|
||||||
onAdd file filestatus
|
onAdd isdirect file filestatus
|
||||||
|
| isdirect = pendingAddChange file
|
||||||
| maybe False isRegularFile filestatus = pendingAddChange file
|
| maybe False isRegularFile filestatus = pendingAddChange file
|
||||||
| otherwise = noChange
|
| otherwise = noChange
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue