[Git][ghc/ghc][wip/hadrian-delete-symlinks] Hadrian: Delete target symlink in createFileLinkUntracked

Ben Gamari gitlab at gitlab.haskell.org
Mon Jun 3 22:38:27 UTC 2019



Ben Gamari pushed to branch wip/hadrian-delete-symlinks at Glasgow Haskell Compiler / GHC


Commits:
29478eb3 by Ben Gamari at 2019-06-03T22:38:21Z
Hadrian: Delete target symlink in createFileLinkUntracked

Previously createFileLinkUntracked would fail if the symlink already
existed.

- - - - -


1 changed file:

- hadrian/src/Hadrian/Utilities.hs


Changes:

=====================================
hadrian/src/Hadrian/Utilities.hs
=====================================
@@ -34,6 +34,7 @@ module Hadrian.Utilities (
     Dynamic, fromDynamic, toDyn, TypeRep, typeOf
     ) where
 
+import Control.Applicative
 import Control.Monad.Extra
 import Data.Char
 import Data.Dynamic (Dynamic, fromDynamic, toDyn)
@@ -296,7 +297,9 @@ createFileLinkUntracked linkTarget link = do
     let dir = takeDirectory link
     liftIO $ IO.createDirectoryIfMissing True dir
     putProgressInfo =<< renderCreateFileLink linkTarget link
-    quietly . liftIO $ IO.createFileLink linkTarget link
+    quietly . liftIO $ do
+        IO.removeFile link <|> return ()
+        IO.createFileLink linkTarget link
 
 -- | Link a file tracking the link target. Create the target directory if
 -- missing.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/29478eb3b83b05420fa04a9324c6a0b9e0f85382

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/29478eb3b83b05420fa04a9324c6a0b9e0f85382
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190603/ec678afc/attachment.html>


More information about the ghc-commits mailing list