fixing another file not closed warning on new vol handler and special case where...
authorEduardo Robles Elvira <edulix@wadobo.com>
Wed, 6 Nov 2013 11:51:39 +0000 (12:51 +0100)
committerEduardo Robles Elvira <edulix@wadobo.com>
Wed, 6 Nov 2013 11:51:39 +0000 (12:51 +0100)
deltatar/deltatar.py

index eb8b83e..eb4f6f5 100644 (file)
@@ -570,6 +570,9 @@ class DeltaTar(object):
             if not os.path.isabs(volume_path):
                 volume_path = os.path.join(cwd, volume_path)
 
+            if tarobj.fileobj is not None:
+                tarobj.fileobj.close()
+
             tarobj.open_volume(volume_path)
 
         # wraps some args from context into the handler
@@ -956,7 +959,11 @@ class DeltaTar(object):
                 Read each member and return it as a stat dict
                 '''
                 tarinfo = self.tar_obj.__iter__().__next__()
-                if not tarinfo or tarinfo == self.last_member:
+                # NOTE: here we compare if tarinfo.path is the same as before
+                # instead of comparing the tarinfo object itself because the
+                # object itself might change for multivol tarinfos
+                if tarinfo is None or (self.last_member is not None and\
+                    self.delta_tar.unprefixed(tarinfo.path) == self.delta_tar.unprefixed(self.last_member.path)):
                     raise StopIteration
 
                 self.last_member = tarinfo