else:
_size_left = lambda: tarinfo.size
- # If there's no data to follow, finish
- if not fileobj:
- if self.save_to_members:
- self.members.append(tarinfo)
- return
-
- target_size_left = _size_left()
- source_size_left = tarinfo.size
- assert tarinfo.volume_offset == 0
-
- # we only split volumes in the middle of a file, that means we have
- # to write at least one block
- if target_size_left < BLOCKSIZE:
- target_size_left = BLOCKSIZE
-
# below attributes aren’t present with other compression methods
init_e = getattr (self.fileobj, "_init_write_encrypt", None)
init_c = getattr (self.fileobj, "_init_write_gz" , None)
if init_e is not None: init_e (tarinfo.name)
if init_c is not None: init_c ()
+ # If there's no data to follow, finish
+ if not fileobj:
+ new_item_hook ()
+ if self.save_to_members:
+ self.members.append(tarinfo)
+ return
+
+ target_size_left = _size_left()
+ source_size_left = tarinfo.size
+ assert tarinfo.volume_offset == 0
+
+ # we only split volumes in the middle of a file, that means we have
+ # to write at least one block
+ if target_size_left < BLOCKSIZE:
+ target_size_left = BLOCKSIZE
+
# loop over multiple volumes
while source_size_left > 0: