Skip to content

windows: birthtime and ctime #8730

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

Open
ThomasWaldmann opened this issue Apr 9, 2025 · 2 comments
Open

windows: birthtime and ctime #8730

ThomasWaldmann opened this issue Apr 9, 2025 · 2 comments

Comments

@ThomasWaldmann
Copy link
Member

From: https://docs.python.org/3.12/library/os.html

"""
Changed in version 3.12: st_birthtime[_ns] is now available on Windows.
"""

"""
Changed in version 3.12: The st_ctime attribute of a stat result is deprecated on Windows. The file creation time is properly available as st_birthtime, and in the future st_ctime may be changed to return zero or the metadata change time, if available.
"""

"""
Changed in version 3.12: st_ctime_ns is deprecated on Windows. Use st_birthtime_ns for the file creation time. In the future, st_ctime will contain the time of the most recent metadata change, as for other platforms.
"""

"""
Changed in version 3.12: On Windows, st_ctime is deprecated. Eventually, it will contain the last metadata change time, for consistency with other platforms, but for now still contains creation time. Use st_birthtime for the creation time.
"""

These are nice consistency changes with the goal of making windows timestamp semantics closer to posix OSes like linux.

@songxiaocheng
Copy link
Contributor

I couldn't find any Windows-specific handling for timestamp restoration, even though Borg always stores ctime and birthtime where available. Am I missing something here?

@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Apr 15, 2025

Looks like restore_attrs only deals with mtime/atime on windows right now.

Guess for now, we only want to add archiving birthtime on windows:

If st has birthtime_ns attribute, we use that (should work for py312+).

Otherwise we fall back to ctime_ns (which should have the birthtime for older pythons).

When the day comes and they release a python that has "change time" available in ctime_ns, we can also add archiving ctime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants