From: Aaron M. Ucko Date: Mon, 30 May 2011 23:02:59 +0000 (-0400) Subject: index.py: factor out an Entry._fixup_time method. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=4cb8d3c09194109eb145428002df9e392f9ec7d5;p=packages%2Fb%2Fbup.git index.py: factor out an Entry._fixup_time method. Factor Entry._fixup_time out of Entry._fixup to reduce (minor) logic duplication and prepare for upcoming tweaks to timestamp indexing. --- diff --git a/lib/bup/index.py b/lib/bup/index.py index 460a52f..10f8309 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -120,14 +120,16 @@ 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 + self.mtime = self._fixup_time(self.mtime) + self.ctime = self._fixup_time(self.ctime) + + def _fixup_time(self, t): + if t < -0x80000000: # can happen in NTFS on 64-bit linux + return 0 + elif t > 0x7fffffff: + return 0x7fffffff + else: + return t def is_valid(self): f = IX_HASHVALID|IX_EXISTS