summaryrefslogtreecommitdiff
path: root/Assistant/Threads/Watcher.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-29 16:17:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-29 16:17:13 -0400
commit1e5aca5087e573aa93b4b6efe7c6f5abd90d0001 (patch)
treee54552bdc584b338d58003eb6015074cf89465c6 /Assistant/Threads/Watcher.hs
parent7d7b03e9ceab25efad67fc99e5b0813d210b1381 (diff)
New annex.largefiles setting, which configures which files `git annex add` and the assistant add to the annex.
I would have sort of liked to put this in .gitattributes, but it seems it does not support multi-word attribute values. Also, making this a single config setting makes it easy to only parse the expression once. A natural next step would be to make the assistant `git add` files that are not annex.largefiles. OTOH, I don't think `git annex add` should `git add` such files, because git-annex command line tools are not in the business of wrapping git command line tools.
Diffstat (limited to 'Assistant/Threads/Watcher.hs')
-rw-r--r--Assistant/Threads/Watcher.hs24
1 files changed, 16 insertions, 8 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 8d06e6659..84193de20 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -35,6 +35,7 @@ import Annex.Direct
import Annex.Content.Direct
import Annex.CatFile
import Annex.Link
+import Annex.FileMatcher
import Git.Types
import Config
import Utility.ThreadScheduler
@@ -77,8 +78,9 @@ watchThread = namedThread "Watcher" $
runWatcher :: Assistant ()
runWatcher = do
startup <- asIO1 startupScan
+ matcher <- liftAnnex $ largeFilesMatcher
direct <- liftAnnex isDirect
- addhook <- hook $ if direct then onAddDirect else onAdd
+ addhook <- hook $ if direct then onAddDirect matcher else onAdd matcher
delhook <- hook onDel
addsymlinkhook <- hook $ onAddSymlink direct
deldirhook <- hook onDelDir
@@ -166,16 +168,22 @@ runHandler handler file filestatus = void $ do
liftAnnex $ Annex.Queue.flushWhenFull
recordChange change
-onAdd :: Handler
-onAdd file filestatus
- | maybe False isRegularFile filestatus = pendingAddChange file
+checkAdd :: FileMatcher -> FilePath -> Assistant (Maybe Change)
+checkAdd matcher file = ifM (liftAnnex $ checkFileMatcher matcher file)
+ ( pendingAddChange file
+ , noChange
+ )
+
+onAdd :: FileMatcher -> Handler
+onAdd matcher file filestatus
+ | maybe False isRegularFile filestatus = checkAdd matcher file
| otherwise = noChange
{- In direct mode, add events are received for both new files, and
- modified existing files. Or, in some cases, existing files that have not
- really been modified. -}
-onAddDirect :: Handler
-onAddDirect file fs = do
+onAddDirect :: FileMatcher -> Handler
+onAddDirect matcher file fs = do
debug ["add direct", file]
v <- liftAnnex $ catKeyFile file
case (v, fs) of
@@ -184,9 +192,9 @@ onAddDirect file fs = do
( noChange
, do
liftAnnex $ changedDirect key file
- pendingAddChange file
+ checkAdd matcher file
)
- _ -> pendingAddChange file
+ _ -> checkAdd matcher file
{- A symlink might be an arbitrary symlink, which is just added.
- Or, if it is a git-annex symlink, ensure it points to the content