Implement proper symlink support in `ReadTarFS` by althonos · Pull Request #426 · PyFilesystem/pyfilesystem2

Type of changes

  • Bug fix
  • New feature

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

The current version of ReadTarFS does not support symlinks properly where Tar files do. This PR changes the following:

OSFS like behaviour for Info

  • Info.is_dir is True for symlinks that map to existing directories.
  • ReadTarFS.isdir(path) returns True if path is a symlink that maps to an existing directory.
  • ReadTarFS.isfile(path) returns True if the path is a symlink that maps to an existing file.
  • ReadTarFs.islink(path) return True if the path is a symlink (that can also be dangling).

Transparent handling of symlinks

  • ReadTarFS.openbin(path) also works if path is a symlink that maps to an existing file.
  • ReadTarFS.listdir(path) also works if path is a symlink that maps to an existing file.

Closes #409 and partially addresses #425.