From: Eduardo Robles Elvira Date: Wed, 18 Sep 2013 13:00:20 +0000 (+0200) Subject: small documentation fix, improving jsonpath comparator for directories, as their... X-Git-Tag: v2.2~102 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=fc8fdcbcbb19af17f2861fcb8398c9a9143cb3ac;p=python-delta-tar small documentation fix, improving jsonpath comparator for directories, as their size dont matter, and improving it also to not compare uid or gid if not superuser --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index 213dfb1..4a722e8 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -406,18 +406,29 @@ class DeltaTar(object): ''' Return if the dicts are equal in the stat keys ''' - keys = [u'gid', u'type', u'mode',u'size', u'uid', u'mtime', + keys = [u'type', u'mode',u'size', u'mtime', # TODO: check how to restore this correctly if possible # u'inode', u'ctime' ] + # only if user is root, then also check gid/uid. otherwise do not check it, + # because tarfile can chown in case of being superuser + if hasattr(os, "geteuid") and os.geteuid() == 0: + keys.append('gid') + keys.append('uid') + if (not d1 and d2 != None) or (d1 != None and not d2): return False if self.prefixed(d1.get('path', -1), listsnapshot_equal) != self.prefixed(d2.get('path', -2), listsnapshot_equal): return False + type = d1.get('type', '') + for key in keys: + # size doesn't matter for directories + if type == 'directory' and key == 'size': + continue if d1.get(key, -1) != d2.get(key, -2): return False return True @@ -967,7 +978,6 @@ class DeltaTar(object): Restores a backup. Parameters: - - backup_path: path where the back up will is stored. - target_path: path to restore. - backup_indexes_paths: path to backup indexes, in descending date order. The indexes indicate the location of their respective backup volumes,