Skip to content

Too many levels of symbolic links #31

Description

@jhagege

Hi, thanks for the great library.

When the folder tree contains a symlink loop, dirhash recurses indefinitely and raises: OSError: [Errno 62] Too many levels of symbolic links: '<…>/test/fixtures/e/symlink'

This is the function call I am using:

    dirhash_result = dirhash(
        folder_path,
        "sha256",
        match=["*"],
        ignore=default_excludes,
        linked_dirs=False,
        linked_files=False,
        allow_cyclic_links=True,
    )

Steps to Reproduce
Point to a directory that includes a symlink cycle. For example: (attaching here for reproducibility - tar-fs_2.1.1-sp1_CVE-2024-12905.zip)

    tar-fs_2.1.1-sp1_CVE-2024-12905/
      source/
        test/
          fixtures/
            e/
              symlink/  →  ../../../../../…   (cycle)

Expected Behavior
should handle symlink loops gracefully—by skipping symlinks entirely based on the parameters of the function call.

Stack trace
File ".../create_dataset_from_metadata.py", line 73, in _deduplicate_folders
folder_hash = compute_sha256_of_folder(folder_path)
File ".../utils.py", line 34, in compute_sha256_of_folder
dirhash_result = dirhash(
File ".../.venv/lib/python3.12/site-packages/dirhash/init.py", line 153, in dirhash
return dirhash_impl(...)
File ".../scantree/_scan.py", line 303, in _scantree_recursive
dir_node = _scantree_recursive(subpath, **fwd_kwargs)
File ".../scantree/_filter.py", line 44, in include
if recursion_path.is_dir() and not self.linked_dirs:
File ".../scantree/_path.py", line 81, in is_dir
return self._dir_entry.is_dir(follow_symlinks=follow_symlinks)
OSError: [Errno 62] Too many levels of symbolic links: '…/test/fixtures/e/symlink'

Would appreciate guidance on how to fix, thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions