]> arthur.barton.de Git - bup.git/commitdiff
Fixup ctime/mtime that are outside a 32-bit range.
authorAvery Pennarun <apenwarr@gmail.com>
Thu, 9 Sep 2010 05:42:21 +0000 (22:42 -0700)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 9 Sep 2010 05:42:59 +0000 (22:42 -0700)
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 <apenwarr@gmail.com>
lib/bup/index.py

index 2818fb534a622b6e0e82f8fa0146745e08b73935..348b73d8ea45a1ce16ff973161a8edd19cd4fcc2 100644 (file)
@@ -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