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,
|
finishIngestUnlocked,
|
||||||
cleanOldKeys,
|
cleanOldKeys,
|
||||||
addLink,
|
addLink,
|
||||||
|
addSymlink,
|
||||||
makeLink,
|
makeLink,
|
||||||
addUnlocked,
|
addUnlocked,
|
||||||
CheckGitIgnore(..),
|
CheckGitIgnore(..),
|
||||||
|
|
|
@ -181,10 +181,19 @@ start o si file addunlockedmatcher = do
|
||||||
_ -> add
|
_ -> add
|
||||||
fixuplink key =
|
fixuplink key =
|
||||||
starting "add" (ActionItemTreeFile file) si $
|
starting "add" (ActionItemTreeFile file) si $
|
||||||
addingExistingLink file key $ do
|
addingExistingLink file key $
|
||||||
liftIO $ removeFile (fromRawFilePath file)
|
withOtherTmp $ \tmp -> do
|
||||||
addLink (checkGitIgnoreOption o) file key Nothing
|
let tmpf = fromRawFilePath tmp </> fromRawFilePath file
|
||||||
next $ cleanup key =<< inAnnex key
|
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 =
|
fixuppointer key =
|
||||||
starting "add" (ActionItemTreeFile file) si $
|
starting "add" (ActionItemTreeFile file) si $
|
||||||
addingExistingLink file key $ do
|
addingExistingLink file key $ do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue