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

std.file.setTimes: on macOS use setattrlist to avoid truncating timestamp precision to microseconds #7466

Merged
merged 1 commit into from May 19, 2020

Conversation

n8sh
Copy link
Member

@n8sh n8sh commented Apr 29, 2020

This was brought to my attention by a unit test in CyberShadow/ae that was failing on macOS because it was storing a result of timeLastModified then using the stored value as an argument to setTimes and expecting that the next call to timeLastModified would yield the same result as the stored value. The problem is that core.sys.posix.sys.stat does not have utimensat for macOS, which is because it only became available in macOS starting from version 10.13 which was released in 2017. As an alternative setattrlist can be used with any version of macOS to set timestamps with the same precision as utimensat.

@n8sh n8sh requested a review from CyberShadow as a code owner April 29, 2020 04:35
@dlang-bot
Copy link
Contributor

dlang-bot commented Apr 29, 2020

Thanks for your pull request, @n8sh!

Bugzilla references

Auto-close Bugzilla Severity Description
20785 normal std.file.setTimes: on macOS use setattrlist to avoid truncating timestamp precision to microseconds

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + phobos#7466"

@CyberShadow
Copy link
Member

Thank you!

What do you think about adding the extern(C) declarations to Druntime first, then using them here?

@n8sh
Copy link
Member Author

n8sh commented Apr 29, 2020

Created dlang/druntime#3076. Let's see where it goes.

@n8sh n8sh force-pushed the issue-20785 branch 2 times, most recently from f91d910 to 055e786 Compare April 29, 2020 06:40
@n8sh n8sh changed the base branch from master to stable May 13, 2020 09:03
@n8sh n8sh changed the base branch from stable to master May 13, 2020 09:03
@n8sh n8sh changed the base branch from master to stable May 13, 2020 09:07
@n8sh n8sh removed the Enhancement label May 13, 2020
@n8sh
Copy link
Member Author

n8sh commented May 13, 2020

Changed this PR to target stable. Please consider moving forward with this bug fix without waiting for dlang/druntime#3076. If/when that PR is accepted the code here can be updated to use it.

…d truncating timestamp precision to microseconds
@dlang-bot dlang-bot merged commit 3988422 into dlang:stable May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants