From: Eduardo Robles Elvira Date: Mon, 30 Sep 2013 07:58:55 +0000 (+0200) Subject: fixing last two unit tests bugs, realted to multivol and tar iterator X-Git-Tag: v2.2~91 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=6bca471cf1920758d7bdcfa5b2214f5e3bda9011;p=python-delta-tar fixing last two unit tests bugs, realted to multivol and tar iterator * when a file was split in two volumes, the tarinfo from the second volume was read twice * tar iterator failed when reading an empty volume because instead of returning None, it tried to read position 0 and when reading from _Stream thats not allowed --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index 83664c6..d12938e 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -909,6 +909,7 @@ class DeltaTar(object): self.delta_tar = delta_tar self.tar_path = tar_path self.tar_obj = None + self.last_member = None self.__enter__() def __iter__(self): @@ -943,10 +944,12 @@ class DeltaTar(object): ''' Read each member and return it as a stat dict ''' - self.last_member = tarinfo = self.tar_obj.next() - if not tarinfo: + tarinfo = self.tar_obj.next() + if not tarinfo or tarinfo == self.last_member: raise StopIteration + self.last_member = tarinfo + ptype = 'unknown' if tarinfo.isfile(): ptype = 'file' diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index ba8737b..354d953 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -2717,7 +2717,7 @@ class TarFile(object): # to self.open_volume self.volume_number += 1 self.new_volume_handler(self, self.base_name, self.volume_number) - tarinfo = self.firstmember + tarinfo = self.next() source = self.extractfile(tarinfo) iterate = True @@ -2833,8 +2833,11 @@ class TarFile(object): self.firstmember = None return m - # Read the next block. - self.fileobj.seek(self.offset) + # Read the next block, unless there's none + if isinstance(self.fileobj, _Stream) and self.offset < self.fileobj.pos: + return None + else: + self.fileobj.seek(self.offset) tarinfo = None while True: try: