File#mtime does not behave like it does in MRI in respect to renamed and deleted files on POSIX #5073
Milestone
Comments
Confirmed. I believe I have the fix. |
headius
added a commit
that referenced
this issue
Mar 19, 2018
This is fixed for 9.1.17. Perhaps you could add a spec for this to https://github.com/ruby/spec? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Expected Behavior
File#mtime doesn't return the same data for File#stat#mtime when the file has been renamed or deleted since the filehandle was opened (if the file has been removed, it throws an exception; if the file has been renamed, it silently gets the wrong data). MRI gets this data from the open filehandle and therefore gets the correct mtime. There are probably other methods on File that are shortcuts for stat that have this same issue. #size appears to have the correct behavior, but #ctime and #atime do not.
Here's an example program that works on MRI (printing "true" twice) but crashes in Jruby:
In MRI
Note that in MRI on Windows, this fails as well, due to Windows files being locked for deletion and renaming when they are open for reading, so it throws a permission denied error. This version works in MRI on Windows:
Actual Behavior
The text was updated successfully, but these errors were encountered: