From 50227056b7ff75a43fc94a14f4cb744455d22a66 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 29 Mar 2013 16:54:59 -0400 Subject: assistant: Check small files into git directly. --- Assistant/Threads/Watcher.hs | 16 ++++++++++------ Assistant/Types/Changes.hs | 6 +++--- debian/changelog | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs index 84193de20..c2ba90ebe 100644 --- a/Assistant/Threads/Watcher.hs +++ b/Assistant/Threads/Watcher.hs @@ -168,15 +168,19 @@ runHandler handler file filestatus = void $ do liftAnnex $ Annex.Queue.flushWhenFull recordChange change -checkAdd :: FileMatcher -> FilePath -> Assistant (Maybe Change) -checkAdd matcher file = ifM (liftAnnex $ checkFileMatcher matcher file) +{- Small files are added to git as-is, while large ones go into the annex. -} +add :: FileMatcher -> FilePath -> Assistant (Maybe Change) +add bigfilematcher file = ifM (liftAnnex $ checkFileMatcher bigfilematcher file) ( pendingAddChange file - , noChange + , do + liftAnnex $ Annex.Queue.addCommand "add" + [Params "--force --"] [file] + madeChange file AddFileChange ) onAdd :: FileMatcher -> Handler onAdd matcher file filestatus - | maybe False isRegularFile filestatus = checkAdd matcher file + | maybe False isRegularFile filestatus = add matcher file | otherwise = noChange {- In direct mode, add events are received for both new files, and @@ -192,9 +196,9 @@ onAddDirect matcher file fs = do ( noChange , do liftAnnex $ changedDirect key file - checkAdd matcher file + add matcher file ) - _ -> checkAdd matcher file + _ -> add 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 diff --git a/Assistant/Types/Changes.hs b/Assistant/Types/Changes.hs index 651085947..9729acfbd 100644 --- a/Assistant/Types/Changes.hs +++ b/Assistant/Types/Changes.hs @@ -14,11 +14,11 @@ import Utility.TSet import Data.Time.Clock import Control.Concurrent.STM -data ChangeInfo = AddChange Key | LinkChange (Maybe Key) | RmChange +data ChangeInfo = AddKeyChange Key | AddFileChange | LinkChange (Maybe Key) | RmChange deriving (Show, Eq) changeInfoKey :: ChangeInfo -> Maybe Key -changeInfoKey (AddChange k) = Just k +changeInfoKey (AddKeyChange k) = Just k changeInfoKey (LinkChange (Just k)) = Just k changeInfoKey _ = Nothing @@ -60,6 +60,6 @@ finishedChange :: Change -> Key -> Change finishedChange c@(InProcessAddChange { keySource = ks }) k = Change { changeTime = changeTime c , _changeFile = keyFilename ks - , changeInfo = AddChange k + , changeInfo = AddKeyChange k } finishedChange c _ = c diff --git a/debian/changelog b/debian/changelog index 241fd4bde..815b39a6c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,7 @@ git-annex (4.20130324) UNRELEASED; urgency=low such as csh. * New annex.largefiles setting, which configures which files `git annex add` and the assistant add to the annex. + * assistant: Check small files into git directly. -- Joey Hess Mon, 25 Mar 2013 10:21:46 -0400 -- cgit v1.2.3