Use st_birthtime for file created timestamp on macOS/BSD#1594
Use st_birthtime for file created timestamp on macOS/BSD#1594minrk merged 3 commits intojupyter-server:mainfrom
Conversation
Previously, the 'created' field in file models always used st_ctime, which on Unix is inode change time (not creation time). On macOS and BSD, st_birthtime provides the actual file creation time. Changes: - Add _get_created_timestamp() helper that prefers st_birthtime when available and valid (non-negative, finite, numeric) - Fall back to st_ctime on Linux/Windows or when st_birthtime is invalid - Add OverflowError to timestamp exception handling for edge cases - Add comprehensive tests for timestamp behavior and edge cases This improves accuracy of the 'created' field on macOS while maintaining backwards compatibility on other platforms. Instrumental in implementing 'Created' column in JupyterLab and solving jupyter/notebook#7797
|
I guess it fixes a bug of "created" being the same as "last_modified" on some OSes, so adding bug |
|
The CI failures are unrelated to the changes in this PR:
All tests related to the I don't have permissions to restart the CI workflow - could a maintainer please re-run the failed jobs? |
|
I kicked the tests.
|
Instrumental in implementing 'Created' column in JupyterLab and solving jupyter/notebook#7797
On macOS/BSD,
st_birthtimeprovides the actual file creation time, whilest_ctime(currently used) is inode change time that updates on chmod, chown, etc.Changes:
_get_created_timestamp()helper that usesst_birthtimewhen available and validst_ctimeon Linux/Windows or whenst_birthtimeis invalidOverflowErrorto timestamp exception handlingcreatedsourcest_birthtimest_ctime(creation time)st_ctime(inode change time)AI Disclosure: Developed with Claude Code (Opus 4.5); code review via Cursor Agents (opus-4.5-thinking, gpt-5.2-high, gemini-3-pro). All code reviewed by author.