Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a4f651a2
Commit
a4f651a2
authored
Jul 20, 2004
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF #857297 and 916874, improve handling of hard links when extracting
parent
0662f8a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletion
+30
-1
Lib/tarfile.py
Lib/tarfile.py
+6
-1
Lib/test/test_tarfile.py
Lib/test/test_tarfile.py
+21
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tarfile.py
View file @
a4f651a2
...
...
@@ -1294,6 +1294,10 @@ class TarFile(object):
else
:
tarinfo
=
self
.
getmember
(
member
)
# Prepare the link target for makelink().
if
tarinfo
.
islnk
():
tarinfo
.
_link_target
=
os
.
path
.
join
(
path
,
tarinfo
.
linkname
)
try
:
self
.
_extract_member
(
tarinfo
,
os
.
path
.
join
(
path
,
tarinfo
.
name
))
except
EnvironmentError
,
e
:
...
...
@@ -1466,7 +1470,8 @@ class TarFile(object):
if
tarinfo
.
issym
():
os
.
symlink
(
linkpath
,
targetpath
)
else
:
os
.
link
(
linkpath
,
targetpath
)
# See extract().
os
.
link
(
tarinfo
.
_link_target
,
targetpath
)
except
AttributeError
:
if
tarinfo
.
issym
():
linkpath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
tarinfo
.
name
),
...
...
Lib/test/test_tarfile.py
View file @
a4f651a2
...
...
@@ -293,6 +293,24 @@ class WriteGNULongTest(unittest.TestCase):
self
.
_test
((
"longnam/"
*
127
)
+
"longname_"
,
(
"longlnk/"
*
127
)
+
"longlink_"
)
class
ExtractHardlinkTest
(
BaseTest
):
def
test_hardlink
(
self
):
"""Test hardlink extraction (bug #857297)
"""
# Prevent errors from being caught
self
.
tar
.
errorlevel
=
1
self
.
tar
.
extract
(
"0-REGTYPE"
,
dirname
())
try
:
# Extract 1-LNKTYPE which is a hardlink to 0-REGTYPE
self
.
tar
.
extract
(
"1-LNKTYPE"
,
dirname
())
except
EnvironmentError
,
e
:
import
errno
if
e
.
errno
==
errno
.
ENOENT
:
self
.
fail
(
"hardlink not extracted properly"
)
# Gzip TestCases
class
ReadTestGzip
(
ReadTest
):
comp
=
"gz"
...
...
@@ -337,6 +355,9 @@ def test_main():
WriteGNULongTest
,
]
if
hasattr
(
os
,
"link"
):
tests
.
append
(
ExtractHardlinkTest
)
if
gzip
:
tests
.
extend
([
ReadTestGzip
,
ReadStreamTestGzip
,
...
...
Misc/NEWS
View file @
a4f651a2
...
...
@@ -39,6 +39,9 @@ Extension modules
Library
-------
-
Bug
#
857297
/
Patch
#
916874.
Fix
an
error
when
extracting
a
hard
link
from
a
tarfile
.
-
Patch
#
846659.
Fix
an
error
in
tarfile
.
py
when
using
GNU
longname
/
longlink
creation
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment