Skip to content

Comments

Use st_birthtime for file created timestamp on macOS/BSD#1594

Merged
minrk merged 3 commits intojupyter-server:mainfrom
ktaletsk:created-timestamp
Feb 13, 2026
Merged

Use st_birthtime for file created timestamp on macOS/BSD#1594
minrk merged 3 commits intojupyter-server:mainfrom
ktaletsk:created-timestamp

Conversation

@ktaletsk
Copy link
Contributor

Instrumental in implementing 'Created' column in JupyterLab and solving jupyter/notebook#7797

On macOS/BSD, st_birthtime provides the actual file creation time, while st_ctime (currently used) is inode change time that updates on chmod, chown, etc.

Changes:

  • Add _get_created_timestamp() helper that uses st_birthtime when available and valid
  • Fall back to st_ctime on Linux/Windows or when st_birthtime is invalid
  • Add OverflowError to timestamp exception handling
  • Add tests for timestamp behavior and edge cases
Platform created source
macOS/BSD st_birthtime
Windows st_ctime (creation time)
Linux 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.

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
@krassowski krassowski added the bug label Jan 30, 2026
@krassowski
Copy link
Collaborator

I guess it fixes a bug of "created" being the same as "last_modified" on some OSes, so adding bug

@ktaletsk
Copy link
Contributor Author

The CI failures are unrelated to the changes in this PR:

  1. test_execution_state (failing on Ubuntu 3.9, Windows 3.9/3.11/3.12) - This is a known flaky test that intermittently fails with "Kernel did not start up in 60 seconds". The test is already marked with @pytest.mark.flaky.

  2. Test Docs - Pre-existing Sphinx documentation warnings (forward reference resolution issues with sphinx_autodoc_typehints) that are treated as errors. These warnings exist on the main branch.

All tests related to the st_birthtime changes pass successfully.

I don't have permissions to restart the CI workflow - could a maintainer please re-run the failed jobs?

@krassowski
Copy link
Collaborator

I kicked the tests.

  1. test_execution_state - I previously tried to fix this in Fix flaky test_execution_state test #1579 - help/other ideas welcome!
  2. Test Docs - this is recent - I opened an issue to track the failing docs test Test Docs started failing on main #1595 - again, thoughts on how to resolve it welcome!

@minrk minrk enabled auto-merge (squash) February 13, 2026 22:13
@minrk minrk merged commit a91b2e7 into jupyter-server:main Feb 13, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants