Author lars.gustaebel
Recipients lars.gustaebel, markgrandi, r.david.murray
Date 2014-08-19.09:47:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
tarfile needs to know the size of a file object beforehand because the tar header is written first followed by the file object's data. If the file object is not based on a real file descriptor, tarfile cannot simply use os.fstat() but the user has to pass the size somehow. And I doubt that it's a good idea to add size arguments to TarFile.add() and .addfile() because it might lead to confusion.

I think tarfile is rather good at exposing the important parts of its low-level api to the programmer, in a way that still leaves some work for him to do but without getting in his way.  I don't see why manually creating TarInfo objects is such a big deal. It is the far superior way because it offers the maximum freedom for the programmer - admittedly at the cost of a slightly steeper learning curve. And we have to account for many different use cases that people have. For example, you don't mention what you think creating directories from scratch should be like in your opinion.

With regard to the usage of the size attribute the documentation for TarFile.addfile() says clearly:

"""Add the TarInfo object tarinfo to the archive. If fileobj is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo()."""
Date User Action Args
2014-08-19 09:47:18lars.gustaebelsetrecipients: + lars.gustaebel, r.david.murray, markgrandi
2014-08-19 09:47:18lars.gustaebelsetmessageid: <>
2014-08-19 09:47:17lars.gustaebellinkissue22208 messages
2014-08-19 09:47:17lars.gustaebelcreate