From: Avery Pennarun Date: Thu, 9 Sep 2010 05:42:21 +0000 (-0700) Subject: Fixup ctime/mtime that are outside a 32-bit range. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=ce2ace5c15b75e72c16821a89f1c1abd109b2f64;p=packages%2Fb%2Fbup.git Fixup ctime/mtime that are outside a 32-bit range. This avoids a DeprecationWarning on python 2.6. That warning probably should have been an error instead. Reported by David Roda. Signed-off-by: Avery Pennarun --- diff --git a/lib/bup/index.py b/lib/bup/index.py index 2818fb5..348b73d 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -4,7 +4,12 @@ from bup.helpers import * EMPTY_SHA = '\0'*20 FAKE_SHA = '\x01'*20 INDEX_HDR = 'BUPI\0\0\0\2' + +# 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' + ENTLEN = struct.calcsize(INDEX_SIG) FOOTER_SIG = '!Q' FOOTLEN = struct.calcsize(FOOTER_SIG) @@ -112,6 +117,14 @@ class Entry: self.gid += 0x100000000 assert(self.uid >= 0) assert(self.gid >= 0) + if self.mtime < -0x80000000: # can happen in NTFS on 64-bit linux + self.mtime = 0 + if self.ctime < -0x80000000: + self.ctime = 0 + if self.mtime > 0x7fffffff: + self.mtime = 0x7fffffff + if self.ctime > 0x7fffffff: + self.ctime = 0x7fffffff def is_valid(self): f = IX_HASHVALID|IX_EXISTS