[New-bugs-announce] [issue44899] tarfile: add support for creating an archive of potentially changing files
Marko Tuononen
report at bugs.python.org
Thu Aug 12 07:43:12 EDT 2021
New submission from Marko Tuononen <marko.tuononen at gmail.com>:
I have a use case where I need to create a tar archive from a collection of potentially changing files. I need to use system resources sparingly and because of that it is not possible to first make a copy of the files.
Current state of the tarfile library: Creating a tar archive is interrupted with an OSError "unexpected end of data" (example below), if any of the files changes when it is collected. Using the tarfile library in streaming mode does not work either. You might find this bug report relevant: https://bugs.python.org/issue26877
File "/usr/lib64/python3.7/tarfile.py", line 1946, in add
self.addfile(tarinfo, f)
File "/usr/lib64/python3.7/tarfile.py", line 1974, in addfile
copyfileobj(fileobj, self.fileobj, tarinfo.size, bufsize=bufsize)
File "/usr/lib64/python3.7/tarfile.py", line 249, in copyfileobj
raise exception("unexpected end of data")
OSError: unexpected end of data
Target state of the tarfile library: Creating a tar archive is not interrupted even if a file changes while collected. The tarfile library's add() method would just return an exit value indicating that some files were changed while being archived. See e.g. how GNU tar handles similar situation: https://man7.org/linux/man-pages/man1/tar.1.html#RETURN_VALUE
----------
components: Library (Lib)
messages: 399443
nosy: marko-tuononen
priority: normal
severity: normal
status: open
title: tarfile: add support for creating an archive of potentially changing files
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44899>
_______________________________________
More information about the New-bugs-announce
mailing list