Skip to content

Commit

Permalink
Don't convert symlinks in audeer.extract_archive()
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Jan 18, 2024
1 parent dc375de commit 63fb613
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 0 additions & 3 deletions audeer/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ def extract_archive(
['a.txt']
"""
archive = safe_path(archive)
destination = safe_path(destination)

if not os.path.exists(archive):
raise FileNotFoundError(
errno.ENOENT,
Expand Down
15 changes: 14 additions & 1 deletion tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def tree(tmpdir, request):


@pytest.mark.parametrize(
"tree, root, files, archive_create, archive_extract, destination, " "expected",
"tree, root, files, archive_create, archive_extract, destination, expected",
[
( # empty
[],
Expand Down Expand Up @@ -340,6 +340,19 @@ def test_archives(
assert not os.path.exists(archive_extract)


def test_archives_symlink(tmpdir):
# Create folder with files and symlink to folder
folder = audeer.mkdir(tmpdir, "folder")
file = audeer.touch(folder, "file.txt")
link = os.path.join(tmpdir, "link")
os.symlink(folder, link)
archive = os.path.join(tmpdir, "archive.zip")

audeer.create_archive(link, [file], archive)
result = audeer.extract_archive(archive, link)
assert result == ["file.txt"]


@pytest.mark.parametrize(
"path,ext,basename",
[
Expand Down

0 comments on commit 63fb613

Please sign in to comment.