fixed overwrite race with git-annex fix

Similar to git-annex add, git-annex fix queued git add, so if a file
got modified before git add ran, the wrong content would be staged,
perhaps a large file content.

Sponsored-by: Brock Spratlen on Patreon
This commit is contained in:
Joey Hess 2022-06-14 14:19:58 -04:00
parent e47219bcb5
commit 64c7f60f7a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 6 additions and 10 deletions

View file

@ -13,10 +13,10 @@ git-annex (10.20220526) UNRELEASED; urgency=medium
content, but where dropping failed due to eg a network problem,
in cases where numcopies checks prevented the resumed
move from dropping the object from the source repository.
* add: When several files are being added, replacing an annex symlink
* add, fix: When several files are being added, replacing an annex symlink
of a file that was already processed with a new large file could
sometimes cause that large file to be added to git. This race has been
fixed.
sometimes cause that large file to be added to git.
These races have been fixed.
* add --batch: Fix handling of a file that is skipped due to being
gitignored.

View file

@ -15,7 +15,7 @@ import qualified Annex
import Annex.ReplaceFile
import Annex.Content
import Annex.Perms
import qualified Annex.Queue
import Annex.Link
import qualified Database.Keys
import qualified Utility.RawFilePath as R
@ -103,9 +103,5 @@ fixSymlink file link = do
#if ! defined(mingw32_HOST_OS)
liftIO $ maybe noop (\t -> touch file t False) mtime
#endif
next $ cleanupSymlink (fromRawFilePath file)
cleanupSymlink :: FilePath -> CommandCleanup
cleanupSymlink file = do
Annex.Queue.addCommand [] "add" [Param "--force", Param "--"] [file]
return True
stageSymlink file =<< hashSymlink link
next $ return True