File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ def match(p):
93
93
# Whether this file is implicitely included / excluded.
94
94
matched = default if hit is None else hit
95
95
sub = list (filter (lambda p : p [1 ], sub ))
96
- if os .path .isdir (cur ):
96
+ if os .path .isdir (cur ) and not os . path . islink ( cur ) :
97
97
# Entirely skip directories if there are no chance any subfile will
98
98
# be included.
99
99
if all (not p [0 ] for p in sub ) and not matched :
Original file line number Diff line number Diff line change @@ -1058,6 +1058,21 @@ def tar_test_negative_mtime_bug(self):
1058
1058
assert tar_data .getnames () == ['th.txt' ]
1059
1059
assert tar_data .getmember ('th.txt' ).mtime == - 3600
1060
1060
1061
+ @pytest .mark .skipif (IS_WINDOWS_PLATFORM , reason = 'No symlinks on Windows' )
1062
+ def test_tar_directory_link (self ):
1063
+ dirs = ['a' , 'b' , 'a/c' ]
1064
+ files = ['a/hello.py' , 'b/utils.py' , 'a/c/descend.py' ]
1065
+ base = make_tree (dirs , files )
1066
+ self .addCleanup (shutil .rmtree , base )
1067
+ os .symlink (os .path .join (base , 'b' ), os .path .join (base , 'a/c/b' ))
1068
+ with tar (base ) as archive :
1069
+ tar_data = tarfile .open (fileobj = archive )
1070
+ names = tar_data .getnames ()
1071
+ for member in dirs + files :
1072
+ assert member in names
1073
+ assert 'a/c/b' in names
1074
+ assert 'a/c/b/utils.py' not in names
1075
+
1061
1076
1062
1077
class FormatEnvironmentTest (unittest .TestCase ):
1063
1078
def test_format_env_binary_unicode_value (self ):
You can’t perform that action at this time.
0 commit comments