get rid of racy addLink

The remaining callers all did not rely on it checking gitignore, so were
easy to convert.

They were susceptable to the same overwrite race as add and fix,
although less likely to have it and a narrower window than add's race.

Command.Rekey in passing got an unncessary call to removeFile deleted.
addSymlink handles deleting any existing worktree file.
This commit is contained in:
Joey Hess 2022-06-14 14:40:55 -04:00
parent 7ace804d8e
commit 78a3d44ea0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 15 additions and 47 deletions

View file

@ -33,9 +33,7 @@ Since adding a file to the annex also involves locking it down and
detecting modifications made while generating the key, update-index is
sufficient.
> Update: This is done for `git-annex add`, using addSymlink. But addLink
> is still in use elsewhere, and those other users might also be subject to
> similar races.
> Update: This is fixed.
When it's adding a file unlocked, it already stages the pointer file using
update-index instead so there is no overwrite problem there.
@ -56,5 +54,4 @@ Unsure how to fix this case yet? Maybe it needs to cache the inode,
hash the file content, then verifiy the inode did not change during
hashing, and then also use update-index.
--[[Joey]]