Skip to content
Snippets Groups Projects
Commit 077c093c authored by Francesco Gazzetta's avatar Francesco Gazzetta
Browse files

Warn when a symlink already exists

Does not warn if the existing symlink already points to the correct location

Partial solution to #5491
parent 6ef25232
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,8 @@ import Distribution.Utils.Generic
( writeFileAtomic )
import Distribution.Text
( simpleParse )
import Distribution.Pretty
( prettyShow )
import Control.Exception
( catch )
......@@ -586,11 +588,16 @@ symlinkBuiltPackage :: Verbosity
, [(ComponentTarget, [TargetSelector])] )
-> IO ()
symlinkBuiltPackage verbosity mkSourceBinDir destDir (pkg, components) =
traverse_ (symlinkBuiltExe verbosity (mkSourceBinDir pkg) destDir) exes
traverse_ symlinkAndWarn exes
where
exes = catMaybes $ (exeMaybe . fst) <$> components
exeMaybe (ComponentTarget (CExeName exe) _) = Just exe
exeMaybe _ = Nothing
symlinkAndWarn exe = do
success <- symlinkBuiltExe verbosity (mkSourceBinDir pkg) destDir exe
unless success $ warn verbosity $ "Symlink for "
<> prettyShow exe
<> " already exists. Not overwriting."
-- | Symlink a specific exe.
symlinkBuiltExe :: Verbosity -> FilePath -> FilePath -> UnqualComponentName -> IO Bool
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment