Skip to content
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

TKLBAM DirIndex incorrectly handles mtime #1985

Open
OnGle opened this issue Sep 24, 2024 · 1 comment
Open

TKLBAM DirIndex incorrectly handles mtime #1985

OnGle opened this issue Sep 24, 2024 · 1 comment

Comments

@OnGle
Copy link
Member

OnGle commented Sep 24, 2024

It's not clear (to me) when this bug was introduced, it is possible that it's existed for the entire lifetime of tklbam.

The stat structure's mtime value is now almost always a float. Pre python 2.5 it was an int by default, 2.5 and after it is a float for all systems that support sub-second mtime values. Nowadays, most systems support sub-second mtime values afaik.

The mtime value is handled incorrectly in 2 places:
https://github.com/turnkeylinux/tklbam/blob/ec65887692fe336f121d95fdeb97c8dd31bd01e7/dirindex.py#L71
and
https://github.com/turnkeylinux/tklbam/blob/ec65887692fe336f121d95fdeb97c8dd31bd01e7/dirindex.py#L63

The latter is the real issue, this is the value that will be written to a file by dirindex. In python2, the %x format specifier will accept a float and silently truncate it, then format it as an integer in hex.

Because of this changes.whatschanged will report files as being different, even between a dirindex, and the same dirindex that has been saved to file.

@JedMeister
Copy link
Member

Good find! As discussed offline, initially we'll convert tklbam to modern python - including any existing bugs such as this one. Then we can look at resolving them.

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