Skip to content

Commit ec5f843

Browse files
viclihaoyi
authored andcommitted
Make sure files are readable when traversing source files. (#423)
Mill was trying to read all files found under the source directory to create a digest for each of them. This was causing an error for broken symlinks. At first I believed temporary files should be ignored to avoid this problem, and asked at the gitter channel how to go about this, but overriding the `sources` task as [suggested](https://gitter.im/lihaoyi/mill?at=5ad6cd801130fe3d36eb7655) by @lihaoyi didn't actually help. on a simple scala project, editing a file with Emacs, creates a link file, like: ``` vic@oeiuwq ~/h/foo> ls -la foo/src/ total 8 drwxr-xr-x 4 vic staff 128 Sep 1 12:23 . lrwxr-xr-x 1 vic staff 22 Sep 1 12:23 .#hello.scala -> [email protected] drwxr-xr-x 3 vic staff 96 Sep 1 12:22 .. -rw-r--r-- 1 vic staff 12 Sep 1 12:22 hello.scala ``` So this patch only makes sures that the files (or the symlink here) is actually readable before trying to digest it. Fixes #402
1 parent a6efead commit ec5f843

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main/core/src/mill/eval/PathRef.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object PathRef{
4343
digest.update((value >>> 16).toByte)
4444
digest.update((value >>> 8).toByte)
4545
digest.update(value.toByte)
46-
}else {
46+
} else if (jnio.Files.isReadable(file)) {
4747
val is = jnio.Files.newInputStream(file)
4848
IO.stream(is, digestOut)
4949
is.close()

0 commit comments

Comments
 (0)