small documentation fix, improving jsonpath comparator for directories, as their...
authorEduardo Robles Elvira <edulix@wadobo.com>
Wed, 18 Sep 2013 13:00:20 +0000 (15:00 +0200)
committerEduardo Robles Elvira <edulix@wadobo.com>
Wed, 18 Sep 2013 13:00:20 +0000 (15:00 +0200)
deltatar/deltatar.py

index 213dfb1..4a722e8 100644 (file)
@@ -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,