示例#1
0
 def rbdir_equal(src_rorp, dest_rorp):
     """Like hardlink_equal, but make allowances for data directories"""
     if not src_rorp.index and not dest_rorp.index:
         return 1
     if (src_rorp.index and src_rorp.index[0] == 'rdiff-backup-data' and src_rorp.index == dest_rorp.index):
         # Don't compare dirs - they don't carry significant info
         if dest_rorp.isdir() and src_rorp.isdir():
             return 1
         if dest_rorp.isreg() and src_rorp.isreg():
             # Don't compare gzipped files because it is apparently
             # non-deterministic.
             if dest_rorp.index[-1].endswith('gz'):
                 return 1
             # Don't compare .missing increments because they don't matter
             if dest_rorp.index[-1].endswith('.missing'):
                 return 1
     if compare_eas and not eas_acls._ea_compare_rps(src_rorp, dest_rorp):
         Log("Different EAs in files %s and %s" %
             (src_rorp.get_indexpath(), dest_rorp.get_indexpath()))
         return None
     if compare_acls and not eas_acls._acl_compare_rps(src_rorp, dest_rorp):
         Log(
             "Different ACLs in files %s and %s" %
             (src_rorp.get_indexpath(), dest_rorp.get_indexpath()), 3)
         return None
     if compare_hardlinks:
         if Hardlink.rorp_eq(src_rorp, dest_rorp):
             return 1
     elif src_rorp._equal_verbose(dest_rorp,
                                  compare_ownership=compare_ownership):
         return 1
     Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
     Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
     return None
示例#2
0
def _hardlink_rorp_eq(src_rorp, dest_rorp):
    """Compare two files for hardlink equality, encompassing being hard-linked,
    having the same hashsum, and the same number of link counts."""
    Hardlink.add_rorp(dest_rorp)
    Hardlink.add_rorp(src_rorp, dest_rorp)
    rorp_eq = Hardlink.rorp_eq(src_rorp, dest_rorp)
    if not src_rorp.isreg() or not dest_rorp.isreg() or src_rorp.getnumlinks() == dest_rorp.getnumlinks() == 1:
        if not rorp_eq:
            Log("Hardlink compare error with when no links exist", 3)
            Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
            Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
            return False
    elif src_rorp.getnumlinks() > 1 and not Hardlink.is_linked(src_rorp):
        if rorp_eq:
            Log("Hardlink compare error with first linked src_rorp and no dest_rorp sha1", 3)
            Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
            Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
            return False
        hash.compute_sha1(dest_rorp)
        rorp_eq = Hardlink.rorp_eq(src_rorp, dest_rorp)
        if src_rorp.getnumlinks() != dest_rorp.getnumlinks():
            if rorp_eq:
                Log("Hardlink compare error with first linked src_rorp, with dest_rorp sha1, and with differing link counts", 3)
                Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
                Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
                return False
        elif not rorp_eq:
            Log("Hardlink compare error with first linked src_rorp, with dest_rorp sha1, and with equal link counts", 3)
            Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
            Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
            return False
    elif src_rorp.getnumlinks() != dest_rorp.getnumlinks():
        if rorp_eq:
            Log("Hardlink compare error with non-first linked src_rorp and with differing link counts", 3)
            Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
            Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
            return False
    elif not rorp_eq:
        Log("Hardlink compare error with non-first linked src_rorp and with equal link counts", 3)
        Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
        Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
        return False
    Hardlink.del_rorp(src_rorp)
    Hardlink.del_rorp(dest_rorp)
    return True
示例#3
0
 def hardlink_rorp_eq(src_rorp, dest_rorp):
     Hardlink.add_rorp(dest_rorp)
     Hardlink.add_rorp(src_rorp, dest_rorp)
     rorp_eq = Hardlink.rorp_eq(src_rorp, dest_rorp)
     if not src_rorp.isreg() or not dest_rorp.isreg() or src_rorp.getnumlinks() == dest_rorp.getnumlinks() == 1:
         if not rorp_eq:
             Log("Hardlink compare error with when no links exist exist", 3)
             Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
             Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
             return 0
     elif src_rorp.getnumlinks() > 1 and not Hardlink.is_linked(src_rorp):
         if rorp_eq:
             Log("Hardlink compare error with first linked src_rorp and no dest_rorp sha1", 3)
             Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
             Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
             return 0
         hash.compute_sha1(dest_rorp)
         rorp_eq = Hardlink.rorp_eq(src_rorp, dest_rorp)
         if src_rorp.getnumlinks() != dest_rorp.getnumlinks():
             if rorp_eq:
                 Log("Hardlink compare error with first linked src_rorp, with dest_rorp sha1, and with differing link counts", 3)
                 Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
                 Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
                 return 0
         elif not rorp_eq:
             Log("Hardlink compare error with first linked src_rorp, with dest_rorp sha1, and with equal link counts", 3)
             Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
             Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
             return 0
     elif src_rorp.getnumlinks() != dest_rorp.getnumlinks():
         if rorp_eq:
             Log("Hardlink compare error with non-first linked src_rorp and with differing link counts", 3)
             Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
             Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
             return 0
     elif not rorp_eq:
         Log("Hardlink compare error with non-first linked src_rorp and with equal link counts", 3)
         Log("%s: %s" % (src_rorp.index, Hardlink._get_inode_key(src_rorp)), 3)
         Log("%s: %s" % (dest_rorp.index, Hardlink._get_inode_key(dest_rorp)), 3)
         return 0
     Hardlink.del_rorp(src_rorp)
     Hardlink.del_rorp(dest_rorp)
     return 1