New submission from Michael Gold <mg...@qnx.com>:

When I call tar.gettarinfo (where tar is a TarFile instance), the inode 
information is inserted into tar.inodes.  If I later call tar.gettarinfo on a 
linked file, the returned TarInfo will have type LNKTYPE.

I think it's incorrect to store this information in gettarinfo.  It should be 
done in addfile.

A comment in gettarinfo states "Is it a hardlink to an already archived file?". 
 But tar.inodes is modified in gettarinfo, and there's no reason to expect that 
the file will actually be archived, or will be archived with the same 
properties.  Bad links could result if the returned tarinfo object were 
modified before calling addfile.

I suggest changing the code as follows:
 - Create a static method (or non-member function) to fill in a given TarInfo 
object with stat/lstat/fstat results.  This would need a boolean "dereference" 
parameter.  (No TarFile instance should be required to create a TarInfo.)
 - Have tar.gettarinfo call the above function; then fill in tarinfo.tarfile, 
and modify tarinfo.type to LNKNAME if applicable.  Don't modify self.inodes.
 - In tar.addfile, call fstat, and store the inode info into self.inodes.

----------
components: Library (Lib)
messages: 134220
nosy: lars.gustaebel, mgold-qnx
priority: normal
severity: normal
status: open
title: TarFile.gettarinfo modifies self.inodes
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11899>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to