fix overwrite race with git-annex add of annex symlink
In the unlikely case where git-annex add is run on an annex symlink that is not already added, and while it's processing it, the annex symlink is overwritten with something else, avoid git-annex overwriting that with the symlink again. Sponsored-by: Jack Hill on Patreon
This commit is contained in:
parent
dd6dec4eb1
commit
5ef79125ad
2 changed files with 14 additions and 4 deletions
|
@ -17,6 +17,7 @@ module Annex.Ingest (
|
|||
finishIngestUnlocked,
|
||||
cleanOldKeys,
|
||||
addLink,
|
||||
addSymlink,
|
||||
makeLink,
|
||||
addUnlocked,
|
||||
CheckGitIgnore(..),
|
||||
|
|
|
@ -181,10 +181,19 @@ start o si file addunlockedmatcher = do
|
|||
_ -> add
|
||||
fixuplink key =
|
||||
starting "add" (ActionItemTreeFile file) si $
|
||||
addingExistingLink file key $ do
|
||||
liftIO $ removeFile (fromRawFilePath file)
|
||||
addLink (checkGitIgnoreOption o) file key Nothing
|
||||
next $ cleanup key =<< inAnnex key
|
||||
addingExistingLink file key $
|
||||
withOtherTmp $ \tmp -> do
|
||||
let tmpf = fromRawFilePath tmp </> fromRawFilePath file
|
||||
liftIO $ moveFile (fromRawFilePath file) tmpf
|
||||
ifM (isSymbolicLink <$> liftIO (getSymbolicLinkStatus tmpf))
|
||||
( do
|
||||
liftIO $ removeFile tmpf
|
||||
addSymlink file key Nothing
|
||||
next $ cleanup key =<< inAnnex key
|
||||
, do
|
||||
liftIO $ moveFile tmpf (fromRawFilePath file)
|
||||
next $ return True
|
||||
)
|
||||
fixuppointer key =
|
||||
starting "add" (ActionItemTreeFile file) si $
|
||||
addingExistingLink file key $ do
|
||||
|
|
Loading…
Reference in a new issue