From 8e019196eb1d2995a585e7f5fa69975152f92a34 Mon Sep 17 00:00:00 2001 From: Eduardo Robles Elvira Date: Wed, 6 Nov 2013 12:51:39 +0100 Subject: [PATCH] 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 --- deltatar/deltatar.py | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) 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 -- 1.7.1