This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author edulix
Recipients christian.heimes, edulix, lars.gustaebel, loewis, serhiy.storchaka
Date 2014-03-11.12:11:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1394539876.95.0.738277144035.issue18321@psf.upfronthosting.co.za>
In-reply-to
Content
I guess I got it wrong, it's not part of the POSIX standard, just part of the GNU tar documentation. About the getmembers and getnames not reflecting the entirety of the archive, it's an optimization I needed and I think ccan be quite handy. It's also consistent with how the tar command works afaik, just listing the contents of the current volume. But it's true that could be done.

Regarding the TarVolumeSet idea, it could work but it's not as easy as that. You don't want to directly do a plain open in there, because you want to be able to deal with read/write modes, with gzip/bzip/Stream class. You also want to give the user maximum flexibility. That's why in my implementation new_volume_handler and open_volume functions are separated. Similarly, we could do something like this:

class MyTarVolumeSet(tarfile.TarVolumeSet):

    def __init__(self, template, max_vol_size):
        self.template = template
        self.max_vol_size = max_vol_size

    def new_volume_handler(self, tarfile, volume_number):
        self.open_volume(self.template % volume_number, tarfile)

volumes = MyTarVolumesSet("test.tar.%03d")
with tarfile.open(fileobj=volumes, mode="w:") as tar:
    for t in tar:
        print(t.name)

Note that the new_volume_handler in this example receives more or less the same params as in my patch (not the base name, because it's already stored in the template), and that the open_volume really abstracts which way it will be opened. It could also have, as in my patch, an optional fileobj parameter, for a new indirection/abstraction.

In any case, this kind of abstraction would still really need some kind of hooking with tarfile, because a multivol tarfile is not exactly the same as a normal tarfile chopped up. This might be doable unilateraly by a smart TarVolumeSet getting the information from the tarfile and modifying/patching anything needed. This is one of the reasons why one would probably would still need access to the tarfile inside the open_volume function.
History
Date User Action Args
2014-03-11 12:11:17edulixsetrecipients: + edulix, loewis, lars.gustaebel, christian.heimes, serhiy.storchaka
2014-03-11 12:11:16edulixsetmessageid: <1394539876.95.0.738277144035.issue18321@psf.upfronthosting.co.za>
2014-03-11 12:11:16edulixlinkissue18321 messages
2014-03-11 12:11:15edulixcreate