tracker icon indicating copy to clipboard operation
tracker copied to clipboard

TKLBAM DirIndex incorrectly handles mtime

Open OnGle opened this issue 1 year ago • 1 comments

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.

OnGle avatar Sep 24 '24 04:09 OnGle

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.

JedMeister avatar Sep 25 '24 02:09 JedMeister