Due to the struct having unsigned timestamps, files with dates between Dec 13,
1901 and Jan 1, 1970 were not representable. This change extends the struct to
be able to pack signed timestamps, which was the spirit of code in _fixup, and
extends the useful range back to 1901. Timestamps prior to 1901 are still
adjusted to zero, as they were before.
There should be no compatibility problems loading packed structures created
before this change, since positive values were truncated at 0x7fffffff.
Signed-off-by: Tim Hatch <tim@timhatch.com>
# FIXME: guess I should have used 64-bit integers to store the mtime/ctime.
# NTFS mtime=0 corresponds to the year 1600, which can't be stored in a 32-bit
# time_t. Next time we update the bupindex format, keep that in mind.
-INDEX_SIG = '!IIIIIQII20sHII'
+INDEX_SIG = '!IiiIIQII20sHII'
ENTLEN = struct.calcsize(INDEX_SIG)
FOOTER_SIG = '!Q'
import os
+import time
from bup import index
from bup.helpers import *
import bup.xstat as xstat
if e.name == ename:
return e
+@wvtest
+def index_negative_timestamps():
+ # Makes 'foo' exist
+ f = file('foo', 'wb')
+ f.close()
+
+ # Dec 31, 1969
+ os.utime("foo", (-86400, -86400))
+ e = index.BlankNewEntry("foo")
+ e.from_stat(xstat.stat("foo"), time.time())
+ assert len(e.packed())
+ WVPASS()
+
+ # Jun 10, 1893
+ os.utime("foo", (-0x90000000, -0x90000000))
+ e = index.BlankNewEntry("foo")
+ e.from_stat(xstat.stat("foo"), time.time())
+ assert len(e.packed())
+ WVPASS()
+
@wvtest
def index_dirty():