diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-07 14:35:46 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-07 14:41:22 -0400 |
commit | 42a370de0544e65fc1f150d3b2406b6683b7e5e1 (patch) | |
tree | 036b3f66c983a33f3dc2915892cf0821eff65010 /Command/Smudge.hs | |
parent | d71bdba6009d522db726121b17980a3d32919f74 (diff) |
update associated files database on smudge and clean
Diffstat (limited to 'Command/Smudge.hs')
-rw-r--r-- | Command/Smudge.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Command/Smudge.hs b/Command/Smudge.hs index 70a318c2d..6cca8035e 100644 --- a/Command/Smudge.hs +++ b/Command/Smudge.hs @@ -16,6 +16,7 @@ import Annex.FileMatcher import Types.KeySource import Backend import Logs.Location +import qualified Database.AssociatedFiles as AssociatedFiles import qualified Data.ByteString.Lazy as B @@ -42,12 +43,13 @@ seek o = commandAction $ -- Smudge filter is fed git file content, and if it's a pointer to an -- available annex object, should output its content. smudge :: FilePath -> CommandStart -smudge _file = do +smudge file = do liftIO $ fileEncoding stdin s <- liftIO $ hGetContents stdin case parsePointer s of Nothing -> liftIO $ putStr s Just k -> do + updateAssociatedFiles k file content <- calcRepo (gitAnnexLocation k) liftIO $ maybe (putStr s) @@ -62,6 +64,7 @@ clean file = do ifM (shouldAnnex file) ( do k <- ingest file + updateAssociatedFiles k file liftIO $ emitPointer k , liftIO cat ) @@ -107,3 +110,10 @@ parsePointer s where s' = take maxsz s maxsz = 81920 + +updateAssociatedFiles :: Key -> FilePath -> Annex () +updateAssociatedFiles k f = do + h <- AssociatedFiles.openDb + liftIO $ do + AssociatedFiles.addDb h k f + AssociatedFiles.closeDb h |