File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 22
33import io
44import json
5+ import os
56
67import libarchive
78from libarchive .entry import format_time
@@ -181,3 +182,32 @@ def write_callback(data):
181182 )
182183 assert archive_entry .uid == 1000
183184 assert archive_entry .gid == 1000
185+
186+
187+ def test_symlinks (tmpdir ):
188+ os .chdir (tmpdir )
189+ with open ('empty' , 'w' ):
190+ pass
191+ with open ('unreadable' , 'w' ) as f :
192+ f .write ('secret' )
193+ os .chmod ('unreadable' , 0 )
194+
195+ os .symlink ('empty' , 'symlink-to-empty' )
196+ os .symlink ('unreadable' , 'symlink-to-unreadable' )
197+
198+ with libarchive .file_writer ('archive.tar' , 'gnutar' ) as archive :
199+ archive .add_files ('symlink-to-empty' , symlink_mode = 'hybrid' )
200+ with pytest .raises (libarchive .ArchiveError ):
201+ archive .add_files ('symlink-to-unreadable' , symlink_mode = 'logical' )
202+ archive .add_files ('symlink-to-unreadable' , symlink_mode = 'physical' )
203+
204+ with libarchive .file_reader ('archive.tar' ) as archive :
205+ entries = iter (archive )
206+ e1 = next (entries )
207+ assert e1 .pathname == 'symlink-to-empty'
208+ assert e1 .isreg
209+ assert e1 .size == 0
210+ e2 = next (entries )
211+ assert e2 .pathname == 'symlink-to-unreadable'
212+ assert e2 .issym
213+ assert e2 .linkpath == 'unreadable'
You can’t perform that action at this time.
0 commit comments