summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-24 14:42:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-24 14:42:19 -0400
commite8abfbba6c46f5a31139d0fb37b592d0db9c278c (patch)
treeb0453d5bb6555de08e5fae50e6a8598a30f00c08
parente0b543af10599f0fe382b39955e89101534d7bcb (diff)
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.
-rw-r--r--Assistant/Threads/Committer.hs6
-rw-r--r--Assistant/Threads/Watcher.hs9
2 files changed, 10 insertions, 5 deletions
diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs
index 213ef11ed..4d623eb0a 100644
--- a/Assistant/Threads/Committer.hs
+++ b/Assistant/Threads/Committer.hs
@@ -147,7 +147,10 @@ delayaddDefault = Nothing
handleAdds :: Maybe Seconds -> [Change] -> Assistant [Change]
handleAdds delayadd cs = returnWhen (null incomplete) $ do
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
unless (null postponed) $
@@ -155,7 +158,6 @@ handleAdds delayadd cs = returnWhen (null incomplete) $ do
returnWhen (null toadd) $ do
added <- catMaybes <$> forM toadd add
- direct <- liftAnnex isDirect
if DirWatcher.eventsCoalesce || null added || direct
then return $ added ++ otherchanges
else do
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index c0a1ea0b9..fd59f1b27 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -35,6 +35,7 @@ import qualified Backend
import Annex.Content
import Annex.CatFile
import Git.Types
+import Config
import Data.Bits.Utils
import qualified Data.ByteString.Lazy as L
@@ -58,7 +59,8 @@ needLsof = error $ unlines
watchThread :: NamedThread
watchThread = NamedThread "Watcher" $ do
startup <- asIO1 startupScan
- addhook <- hook onAdd
+ direct <- liftAnnex isDirect
+ addhook <- hook $ onAdd direct
delhook <- hook onDel
addsymlinkhook <- hook onAddSymlink
deldirhook <- hook onDelDir
@@ -124,8 +126,9 @@ runHandler handler file filestatus = void $ do
liftAnnex $ Annex.Queue.flushWhenFull
recordChange change
-onAdd :: Handler
-onAdd file filestatus
+onAdd :: Bool -> Handler
+onAdd isdirect file filestatus
+ | isdirect = pendingAddChange file
| maybe False isRegularFile filestatus = pendingAddChange file
| otherwise = noChange