diff --git a/secondary.py b/secondary.py index 81e0baea73996665b0284dccd4826558b51fca6e..936e3113c86229069745c611f79010ef58d1c46a 100644 --- a/secondary.py +++ b/secondary.py @@ -68,28 +68,29 @@ class Backup: def check(self, src, dst): if src.name != dst.name: raise Exception('Names differ: %s, %s' % (src, dst)) + dst_path = os.path.join(self.dst_root, dst.name) if src.kind != dst.kind or src.md5 != dst.md5 or src.size != dst.size: self.log.DEBUG('Replace...', src.name, dst.name, src.md5, dst.md5, src.size, dst.size) self.status.replaced += 1 self.delete(dst) self.add(src) - elif os.path.exists(dst.name): + elif os.path.exists(dst_path): changed = False - if src.kind in [ 'F', 'D'] and src.mode != dst.mode: + if src.kind in [ b'F', b'D'] and src.mode != dst.mode: self.log.DEBUG('MODE', dst.name, src.mode, dst.mode) - os.chmod(dst.name, int(src.mode, 8)) + os.chmod(dst_path, int(src.mode, 8)) changed = True - if (src.kind in [ 'F', 'D'] and - src.uid != dst.uid or src.gid != dst.gid): + if (src.kind in [ b'F', b'D'] and + (src.uid != dst.uid or src.gid != dst.gid)): self.log.DEBUG('UID/GID', dst.name, src.uid, src.gid, dst.uid, dst.gid) - os.lchown(dst.name, int(src.uid), int(src.gid)) + os.lchown(dst_path, int(src.uid), int(src.gid)) changed = True - if src.kind == 'F' and src.mtime != dst.mtime: + if src.kind == b'F' and src.mtime != dst.mtime: self.log.DEBUG('MTIME', src.name, src.mtime, dst.mtime) - atime = os.stat(dst.name).st_atime - os.utime(dst.name, (int(atime), int(src.mtime))) + atime = os.stat(dst_path).st_atime + os.utime(dst_path, (int(atime), int(src.mtime))) changed = True if changed: self.status.metadata += 1