From 56835693f551bdd07f6a840cce2d760098eebd82 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 2 Apr 2013 13:13:42 -0400 Subject: 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.) --- Annex/Link.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Annex/Link.hs') diff --git a/Annex/Link.hs b/Annex/Link.hs index 650fc19a1..931836d31 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -60,7 +60,9 @@ getAnnexLinkTarget file = do -} makeAnnexLink :: LinkTarget -> FilePath -> Annex () makeAnnexLink linktarget file = ifM (coreSymlinks <$> Annex.getGitConfig) - ( liftIO $ createSymbolicLink linktarget file + ( liftIO $ do + void $ tryIO $ removeFile file + createSymbolicLink linktarget file , liftIO $ writeFile file linktarget ) -- cgit v1.2.3