Commit 793aeca1 authored by bescoto's avatar bescoto

Mostly tweaks to get the test cases to work


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@337 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 76141dac
Use ctime to check whether files have been changed
Use ctime to check whether files have been changed. See message:
http://mail.gnu.org/archive/html/rdiff-backup-users/2003-06/msg00050.html
by Andrew Bressen.
Include some option to summarize space taken up
Profile 0.13.0
---------[ Medium term ]---------------------------------------
......
......@@ -377,7 +377,7 @@ def Restore(src_rp, dest_rp, restore_as_of = None):
"""
if not restore_root_set: assert restore_set_root(src_rp)
restore_check_paths(src_rp, dest_rp, restore_as_of)
restore_set_fs_globals(Globals.rbdir)
restore_set_fs_globals(dest_rp)
src_rp = restore_init_quoting(src_rp)
restore_check_backup_dir(restore_root, src_rp, restore_as_of)
if restore_as_of:
......@@ -412,7 +412,7 @@ def restore_set_fs_globals(target):
SetConnections.UpdateGlobal('preserve_hardlinks', target_fsa.hardlinks)
SetConnections.UpdateGlobal('change_ownership', target_fsa.ownership)
mirror_fsa = fs_abilities.FSAbilities().init_readwrite(Globals.rbdir)
mirror_fsa = fs_abilities.FSAbilities().init_readonly(Globals.rbdir)
if Globals.chars_to_quote is None: # otherwise already overridden
if mirror_fsa.chars_to_quote:
SetConnections.UpdateGlobal('chars_to_quote',
......
......@@ -43,7 +43,6 @@ class ExtendedAttributes:
"""Equal if all attributes and index are equal"""
assert isinstance(ea, ExtendedAttributes)
return ea.index == self.index and ea.attr_dict == self.attr_dict
def __ne__(self, ea): return not self.__eq__(ea)
def get_indexpath(self): return self.index and '/'.join(self.index) or '.'
......@@ -89,7 +88,7 @@ class ExtendedAttributes:
"""Return true if no extended attributes are set"""
return not self.attr_dict
def compare_rps(rp1, rp2):
def ea_compare_rps(rp1, rp2):
"""Return true if rp1 and rp2 have same extended attributes"""
ea1 = ExtendedAttributes(rp1.index)
ea1.read_from_rp(rp1)
......@@ -183,3 +182,46 @@ class ExtendedAttributesFile(metadata.FlatFile):
return join_eas(basic_iter, ea_iter)
static.MakeClass(ExtendedAttributesFile)
class AccessControlList:
"""Hold a file's access control list information"""
def __init__(self, index, text_acl = None):
"""Initialize object with index and possibly text_acl"""
self.index = index
# self.ACL is a posix1e ACL object
if text_acl is None: self.ACL = None
else: self.ACL = posix1e.ACL(text_acl)
def __eq__(self, acl):
"""Compare self and other access control list"""
return self.index == acl.index and str(self.ACL) == str(acl.ACL)
def __ne__(self, acl): return not self.__eq__(acl)
def get_indexpath(self): return self.index and '/'.join(self.index) or '.'
def get_acl_from_rp(rp):
"""Return text acl from an rpath, or None if not supported"""
try: acl = rp.conn.posix1e.ACL(file=rp.path)
except IOError, exc:
if exc[0] == errno.EOPNOTSUPP: return None
raise
return str(acl)
def acl_compare_rps(rp1, rp2):
"""Return true if rp1 and rp2 have same acls"""
return get_acl_from_rp(rp1) == get_acl_from_rp(rp2)
def ACL2Record(acl):
"""Convert an AccessControlList object into a text record"""
return "# file: %s\n%s" % (acl.get_indexpath(), str(acl.ACL))
def Record2EA(acl):
"""Convert text record to an AccessControlList object"""
XXXX
......@@ -87,7 +87,7 @@ def makedir(mirrordir, incpref):
"""Make file indicating directory mirrordir has changed"""
dirsign = get_inc(incpref, "dir")
dirsign.touch()
rpath.copy_attribs(mirrordir, dirsign)
rpath.copy_attribs(mirrordir, dirsign)
return dirsign
def get_inc(rp, typestr, time = None):
......
......@@ -128,6 +128,7 @@ def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time):
"""
Main.force = 1
Main.restore_root_set = 0
remote_schema = '%s'
#_reset_connections()
if not mirror_local:
......@@ -221,7 +222,7 @@ def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1,
Log("%s: %s" % (dest_rorp.index,
Hardlink.get_indicies(dest_rorp, None)), 3)
return None
if compare_eas and not eas_acls.compare_rps(src_rorp, dest_rorp):
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()), 3)
return None
......@@ -240,7 +241,7 @@ def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1,
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.compare_rps(src_rorp, dest_rorp):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment