summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-04 15:09:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-04 15:09:32 -0400
commitd34345ec823ee2e95e005faae09f9573de24a3d5 (patch)
tree41bedbcb2e689fa5e0b29e5a4f7226c58cbdd04b /Assistant
parent0a959d31d29ed95ff648fcf4027803d3db41ae57 (diff)
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.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/Watcher.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 4eac622f9..38c5c138f 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -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
)