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
fix: fix mtime precision on some filesystems #88
Conversation
Tests still need to be updated! |
6c258ef
to
a88b324
Compare
Codecov Report
@@ Coverage Diff @@
## master #88 +/- ##
=======================================
+ Coverage 98.29% 100% +1.7%
=======================================
Files 4 5 +1
Lines 176 192 +16
Branches 45 48 +3
=======================================
+ Hits 173 192 +19
+ Misses 3 0 -3
Continue to review full report at Codecov.
|
c9ff6b8
to
764be75
Compare
I ended up changing the strategy to a more robust one. After acquiring the lock, I will probe the precision of the filesystem passed in This makes the code much more simple and easy to reason about. |
@alanshaw @hugomrdias you may want to review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
let now = Date.now(); | ||
|
||
if (precision === 's') { | ||
now = Math.ceil(now / 1000) * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fs might be either ceiling, rounding or flooring. ceil
is preferred because of the isStaleLock
check, where we are using a Date.now. This way, the mtime is always set a little bit in the future and the isStaleLock
will always behave correctly.
Closes #82, #87