Commit ead7bb2c0193a30b3638d24f5755ef5a41954620 Parent: bc32e5875aafedc7a724e9ed1a41a12de7f44807 Author: mcol <mcol@posteo.net> Date: 2021-11-27 19:22:01 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-11-27 19:22:01 +0000 remove existing file before creating symlink
src/Templates.hs Modified
@@ -8,7 +8,7 @@ generate, ) where -import Control.Monad (filterM, join, void, (<=<)) +import Control.Monad (filterM, join, void, when, (<=<)) import Control.Monad.Extra (findM) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Reader (ReaderT) @@ -22,8 +22,10 @@ canonicalizePath, createDirectoryLink, createFileLink, + doesPathExist, getSymbolicLinkTarget, pathIsSymbolicLink, + removeFile, ) import qualified System.FilePath as FP import System.IO.Error (tryIOError) @@ -213,5 +215,7 @@ if isLink then do target <- getSymbolicLinkTarget fp + exists <- doesPathExist . toFilePath $ output' + when exists . removeFile . toFilePath $ output' createFileLink target . toFilePath $ output' else copyFile p output'