From: Eduardo Robles Elvira Date: Wed, 6 Nov 2013 11:51:39 +0000 (+0100) Subject: fixing another file not closed warning on new vol handler and special case where... X-Git-Tag: v2.2~76 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=8e019196eb1d2995a585e7f5fa69975152f92a34;p=python-delta-tar fixing another file not closed warning on new vol handler and special case where the last file in a multivolume tar was being repeated in the tar index iterator --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index eb8b83e..eb4f6f5 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -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