fix another potential race with the watcher and direct mode

Watcher wants to rewrite symlink to fix it. But in direct mode, the symlink
could be replaced at any time with file content that has finished being
transferred by some other process. So, just don't touch it.

FWIW, I audited the rest of the assistant for places where it removes
files, and the rest is ok. I have not audited the rest of git-annex.
This commit is contained in:
Joey Hess 2013-03-04 15:09:32 -04:00
parent 1d388d5579
commit c908672f3d

View file

@ -206,8 +206,9 @@ onAddSymlink isdirect file filestatus = go =<< liftAnnex (Backend.lookupFile fil
checkcontent key s
ensurestaged (Just link) s
, do
liftIO $ removeFile file
liftAnnex $ Backend.makeAnnexLink link file
unless isdirect $ do
liftIO $ removeFile file
liftAnnex $ Backend.makeAnnexLink link file
checkcontent key =<< getDaemonStatus
addlink link
)