diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-02 13:13:42 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-02 15:02:00 -0400 |
commit | 56835693f551bdd07f6a840cce2d760098eebd82 (patch) | |
tree | 576a80009ea1cb6fe05f9a196f8421583457fcdf /Assistant/Threads | |
parent | 8ba1f8f3327288bba9e27081d1aa651adbaa1e3e (diff) |
Update working tree files fully atomically
This avoids commit churn by the assistant when eg,
replacing a file with a symlink.
But, just as importantly, it prevents the working tree being left with a
deleted file if git-annex, or perhaps the whole system, crashes at the
wrong time.
(It also probably avoids confusing displays in file managers.)
Diffstat (limited to 'Assistant/Threads')
-rw-r--r-- | Assistant/Threads/Watcher.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs index c41b17434..b20a8d4d7 100644 --- a/Assistant/Threads/Watcher.hs +++ b/Assistant/Threads/Watcher.hs @@ -222,9 +222,9 @@ onAddSymlink isdirect file filestatus = go =<< liftAnnex (Backend.lookupFile fil ifM ((==) (Just link) <$> liftIO (catchMaybeIO $ readSymbolicLink file)) ( ensurestaged (Just link) (Just key) =<< getDaemonStatus , do - unless isdirect $ do - liftIO $ removeFile file - liftAnnex $ Backend.makeAnnexLink link file + unless isdirect $ + liftAnnex $ replaceFile file $ + makeAnnexLink link addLink file link (Just key) ) go Nothing = do -- other symlink |