update associated files database on smudge and clean
This commit is contained in:
parent
a6e5ee0d0e
commit
2cbcb4f1a8
2 changed files with 13 additions and 2 deletions
|
@ -16,6 +16,7 @@ import Annex.FileMatcher
|
||||||
import Types.KeySource
|
import Types.KeySource
|
||||||
import Backend
|
import Backend
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
|
import qualified Database.AssociatedFiles as AssociatedFiles
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as B
|
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
|
-- Smudge filter is fed git file content, and if it's a pointer to an
|
||||||
-- available annex object, should output its content.
|
-- available annex object, should output its content.
|
||||||
smudge :: FilePath -> CommandStart
|
smudge :: FilePath -> CommandStart
|
||||||
smudge _file = do
|
smudge file = do
|
||||||
liftIO $ fileEncoding stdin
|
liftIO $ fileEncoding stdin
|
||||||
s <- liftIO $ hGetContents stdin
|
s <- liftIO $ hGetContents stdin
|
||||||
case parsePointer s of
|
case parsePointer s of
|
||||||
Nothing -> liftIO $ putStr s
|
Nothing -> liftIO $ putStr s
|
||||||
Just k -> do
|
Just k -> do
|
||||||
|
updateAssociatedFiles k file
|
||||||
content <- calcRepo (gitAnnexLocation k)
|
content <- calcRepo (gitAnnexLocation k)
|
||||||
liftIO $ maybe
|
liftIO $ maybe
|
||||||
(putStr s)
|
(putStr s)
|
||||||
|
@ -62,6 +64,7 @@ clean file = do
|
||||||
ifM (shouldAnnex file)
|
ifM (shouldAnnex file)
|
||||||
( do
|
( do
|
||||||
k <- ingest file
|
k <- ingest file
|
||||||
|
updateAssociatedFiles k file
|
||||||
liftIO $ emitPointer k
|
liftIO $ emitPointer k
|
||||||
, liftIO cat
|
, liftIO cat
|
||||||
)
|
)
|
||||||
|
@ -107,3 +110,10 @@ parsePointer s
|
||||||
where
|
where
|
||||||
s' = take maxsz s
|
s' = take maxsz s
|
||||||
maxsz = 81920
|
maxsz = 81920
|
||||||
|
|
||||||
|
updateAssociatedFiles :: Key -> FilePath -> Annex ()
|
||||||
|
updateAssociatedFiles k f = do
|
||||||
|
h <- AssociatedFiles.openDb
|
||||||
|
liftIO $ do
|
||||||
|
AssociatedFiles.addDb h k f
|
||||||
|
AssociatedFiles.closeDb h
|
||||||
|
|
|
@ -275,13 +275,14 @@ In particular:
|
||||||
* Is the smudge filter called at any other time? Seems unlikely but then
|
* Is the smudge filter called at any other time? Seems unlikely but then
|
||||||
there could be situations with a detached work tree or such.
|
there could be situations with a detached work tree or such.
|
||||||
* Does git call any useful hooks when removing a file from the work tree,
|
* Does git call any useful hooks when removing a file from the work tree,
|
||||||
or converting it to not be annexed?
|
or converting it to not be annexed, or for `git mv` of an annexed file?
|
||||||
No!
|
No!
|
||||||
|
|
||||||
From this analysis, any file map generated by the smudge/clean filters
|
From this analysis, any file map generated by the smudge/clean filters
|
||||||
is necessary potentially innaccurate. It may list deleted files.
|
is necessary potentially innaccurate. It may list deleted files.
|
||||||
It may or may not reflect current unstaged changes from the work tree.
|
It may or may not reflect current unstaged changes from the work tree.
|
||||||
|
|
||||||
|
|
||||||
Follows that any use of the file map needs to verify the info from it,
|
Follows that any use of the file map needs to verify the info from it,
|
||||||
and throw out bad cached info (updating the map to match reality).
|
and throw out bad cached info (updating the map to match reality).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue