Make sure files are readable when traversing source files.#423
Merged
lihaoyi merged 1 commit intocom-lihaoyi:masterfrom Sep 5, 2018
Merged
Make sure files are readable when traversing source files.#423lihaoyi merged 1 commit intocom-lihaoyi:masterfrom
lihaoyi merged 1 commit intocom-lihaoyi:masterfrom
Conversation
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 -> vic@oeiuwq.local.10748 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 com-lihaoyi#402
Member
|
Perhaps using a try-catch around the |
Contributor
Author
|
@lihaoyi Hm, not sure if using a try-catch is the way we should go. I mean, since we are trying to create an InputStream for the file and read from it, we should at least check if the file is readable (which is what this PR does), but if then we try to read it and somehow there's an error reading it (say it's on a network filesystem and network goes down), I believe we should let the IOException go and not just ignore it. Do you have a strong opinion about using the try-catch ? |
Member
|
No i don't have strong opinions, this looks good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
sourcestask as suggested
by @lihaoyi didn't actually help, because it was
T.sourcesmacro who was actuallytriggering the exception.
So, on a simple scala project, editing a file with Emacs, creates a link file, like:
This patch only makes sures that the files (or the symlink here) is actually
readable before trying to digest it.
Fixes #402