Skip to content

Commit

Permalink
hadrian: Handle broken symlinks properly when creating source dist di…
Browse files Browse the repository at this point in the history
…rectories

If we have a broken symlink in the repository, don't try to `need` the symlink
or the target of the symlink. Attempting to do so has `shake` attempt to read the
target to compute its hash, which fails because the target doesn't exist.
  • Loading branch information
wz1000 authored and Marge Bot committed Oct 12, 2024
1 parent c08b68b commit e3eec54
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hadrian/src/Rules/SourceDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ copyFileSourceDist source target = do
error ("source-dist: tried to create non-relative symlink in source dist: " ++ show link_target)
putProgressInfo =<< renderAction ("Create symlink (" ++ link_target ++ ")") source target
isDirectory <- liftIO $ IO.doesDirectoryExist source
when (not isDirectory) $
-- We don't want to call `need` on broken symlinks
linkTargetExists <- liftIO $ IO.doesPathExist link_target
when (not isDirectory && linkTargetExists) $
need [source]
let createLink src tgt
| isDirectory = liftIO $ IO.createDirectoryLink src tgt
Expand Down

0 comments on commit e3eec54

Please sign in to comment.