From: Rob Browning Date: Sun, 24 May 2015 19:55:32 +0000 (-0500) Subject: Move Cygwin uid/gid fixup from index to xstat X-Git-Tag: 0.28-rc1~73 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=6546e8d046570c9d3d13c793d927b4f27fa99eb9;ds=sidebyside Move Cygwin uid/gid fixup from index to xstat Move the Cygwin uid/gid fixup (8417c11948532ba890b862dcad9d37810d482616) from the index to xstat.py so that it will affect metadata too. If Cygwin is still affected by this issue, then it's possible that some existing saves might have incorrect uid/gid values. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/index.py b/lib/bup/index.py index 794ff9f..268716c 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -205,12 +205,6 @@ class Entry: self._fixup() def _fixup(self): - if self.uid < 0: - self.uid += 0x100000000 - if self.gid < 0: - self.gid += 0x100000000 - assert(self.uid >= 0) - assert(self.gid >= 0) self.mtime = self._fixup_time(self.mtime) self.ctime = self._fixup_time(self.ctime) diff --git a/lib/bup/metadata.py b/lib/bup/metadata.py index bef8066..9c6d46a 100644 --- a/lib/bup/metadata.py +++ b/lib/bup/metadata.py @@ -212,6 +212,8 @@ class Metadata: # must be non-negative and < 10**9. def _add_common(self, path, st): + assert(st.st_uid >= 0) + assert(st.st_gid >= 0) self.uid = st.st_uid self.gid = st.st_gid self.atime = st.st_atime diff --git a/lib/bup/xstat.py b/lib/bup/xstat.py index 0eee9b2..7408414 100644 --- a/lib/bup/xstat.py +++ b/lib/bup/xstat.py @@ -81,6 +81,13 @@ else: # Must have these if utimensat isn't available. _bup_lutimes(path, (atime, mtime)) +def _fix_cygwin_id(id): + if id < 0: + id += 0x100000000 + assert(id >= 0) + return id + + class stat_result: @staticmethod def from_xstat_rep(st): @@ -99,6 +106,8 @@ class stat_result: result.st_atime = timespec_to_nsecs(result.st_atime) result.st_mtime = timespec_to_nsecs(result.st_mtime) result.st_ctime = timespec_to_nsecs(result.st_ctime) + result.st_uid = _fix_cygwin_id(result.st_uid) + result.st_gid = _fix_cygwin_id(result.st_gid) return result