Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.3.x] Fix IO.getModifiedTimeOrZero for unnormalized paths #283

Merged
merged 2 commits into from
Jan 22, 2020

Conversation

eed3si9n
Copy link
Member

This is a backport of #273
Fixes sbt/sbt#5224

original description

The fix for long path names on windows,
099aa4f, had the unintended side effect
of causing IO.getModifiedTimeOrZero to throw uncaught IOExceptions when
the path name was not normalized. Specifically, it would throw if the
path was empty or if it had relative components. To fix this, we try to
get the modified time but if the file is not found, we normalize the
path and make it absolute and retry.

This change was primarily made for windows, but it turns out that
IO.getModifiedTimeOrZero(file("")) also didn't work correctly. Naively,
I'd expect the empty path to be expanded to the program working
directory but it would actually just return 0 because the posix native
api did not handle empty strings either. Relative paths did work on
posix before this change.

eed3si9n and others added 2 commits January 18, 2020 20:24
Ref scala/scala#8528

Currently SDKMAN blocks for prompt when there's a new version of SDKMAN. This is an attempted workaround.
The fix for long path names on windows,
099aa4f, had the unintended side effect
of causing IO.getModifiedTimeOrZero to throw uncaught IOExceptions when
the path name was not normalized. Specifically, it would throw if the
path was empty or if it had relative components. To fix this, we try to
get the modified time but if the file is not found, we normalize the
path and make it absolute and retry.

This change was primarily made for windows, but it turns out that
IO.getModifiedTimeOrZero(file("")) also didn't work correctly. Naively,
I'd expect the empty path to be expanded to the program working
directory but it would actually just return 0 because the posix native
api did not handle empty strings either. Relative paths did work on
posix before this change.
@eed3si9n eed3si9n requested a review from eatkins January 19, 2020 01:27
@eed3si9n
Copy link
Member Author

This failed on Travis CI macOS job.

[info] - should handle rapid creation of many subdirectories and files *** FAILED ***
[info]   result was false (SourceModificationWatchSpec.scala:451)

I'm going to restart and see if it passes.

@eed3si9n
Copy link
Member Author

@eatkins I'm going to merge this.

@eed3si9n eed3si9n merged commit afb0a4f into sbt:1.3.x Jan 22, 2020
@eed3si9n eed3si9n deleted the bport/path branch January 22, 2020 21:38
@eatkins
Copy link
Contributor

eatkins commented Jan 22, 2020

My bad. The review request notification slipped through the cracks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants