diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-06 14:29:10 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-06 14:29:10 -0400 |
commit | b819f644ad00c5ad13ba5b249d3e127fd59d8694 (patch) | |
tree | 6882fedee5af6ee4406ef68b9ec1ec50822f64e9 /Annex | |
parent | 91db54076964979b6c50bd7efd0b895c4d416978 (diff) |
close the git add race
There's a race adding a new file to the annex: The file is moved to the
annex and replaced with a symlink, and then we git add the symlink. If
someone comes along in the meantime and replaces the symlink with
something else, such as a new large file, we add that instead. Which could
be bad..
This race is fixed by avoiding using git add, instead the symlink is
directly staged into the index.
It would be nice to make `git annex add` use this same technique.
I have not done so yet because it currently runs git update-index once per
file, which would slow does `git annex add`. A future enhancement would be
to extend the Git.Queue to include the ability to run update-index with
a list of Streamers.
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Branch.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs index c8d0719b0..1dacd5f32 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -35,6 +35,8 @@ import qualified Git.Branch import qualified Git.UnionMerge import qualified Git.UpdateIndex import Git.HashObject +import Git.Types +import Git.FilePath import qualified Git.Index import Annex.CatFile import Annex.Perms @@ -344,5 +346,5 @@ stageJournal = do let path = dir </> file sha <- hashFile h path _ <- streamer $ Git.UpdateIndex.update_index_line - sha (fileJournal file) + sha FileBlob (asTopFilePath $ fileJournal file) removeFile path |