shave sub-second precision off modification time #251
Closed
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.
It seems like System.Directory's
getModificationTime
is now providingsub-second precision if it's available in the underlying system call,
which it seems to be for most systems.
The problem is that when the modification time is stored, the DiffTime,
the number of seconds from midnight, has its sub-second precision
shaved off, effectively becoming 0 the next time it's read. When a
file is then checked to see if it has been modified, the file is
always deemed to have been modified because this time still includes
the sub-second precision, which will almost always be later in time
than 0, unless of course it happened to be 0 to begin with.
This simply shaves the sub-second precision off of the time returned by
getModificationTime
, and thus no longer rebuilds every single fileeach time any one file is saved.
This closes #250
Update: I rebased some extra changes I made and pushed, doubt anyone will be affected. It added back an unrelated newline I removed from a different section of the file, as well as generalized the fix so that it works in both blocks regardless of the version of directory.