Included is a patch that fixes the extraction of
hardlinks in tarfile.py (bug #857297) and a testcase.
Until now tarfile.py extracted hardlinks the same way
as symlinks which worked under certain circumstances:
if the hardlink source is accessible from the current
working directory everything is fine, but if you choose
to extract it to a different location it won't work.
That particular code in tarfile.py dates back to my
good old windoze days where my understanding of unix
filesystem basics was not as profound as it is today :-)
The testcase probably needs some attention regarding
portability. (On platforms that do not have os.link()
it is skipped completely.)
Trying to extract a hardlink and testing for its
existence afterwards is no option here, because it
doesn't necessarily need to be tarfile.py's fault if
this doesn't work. There are many different conditions
involved, especially the filesystem the test is made on.
My current solution is that the testcase tries to
create a link and if it gets an ENOENT (which means the
link's source file cannot be found) it fails. All other
EnvironmentErrors are ignored.
Interestingly this testcase even works on a FAT32
filesystem (on my Linux box) - if the link's source
cannot be found there is an ENOENT (and the test fails
as it should), and if it can be found there is an EPERM
which is ignored.
IMO all this is a bit too much black magic and maybe
the testcase introduces more problems than it actually
solves, so feel free to throw it away.
|