PseudoDirEntry caching ignores follow_symlinks parameter #8

Open
opened 2025-11-15 03:44:11 +00:00 by snegov · 0 comments
Owner

PseudoDirEntry caching ignores follow_symlinks parameter

Priority: Medium
Component: fs.py
Type: Bug

Description

The PseudoDirEntry class caches the results of is_dir(), is_file(), and is_symlink() methods but ignores the follow_symlinks parameter, which could return incorrect results if called with different parameter values.

Location

curateipsum/fs.py:31-63

Current Code

def is_dir(self, follow_symlinks: bool = True) -> bool:
    if self._is_dir is None:
        self._is_dir = os.path.isdir(self.path)
    return self._is_dir

Problem

The caching doesn't account for the follow_symlinks parameter. If you call:

  1. entry.is_dir(follow_symlinks=True) → caches result
  2. entry.is_dir(follow_symlinks=False) → returns cached result from (1), which may be wrong

Proposed Solution

Either:

  1. Remove the parameter if it's not needed
  2. Cache based on the parameter value: self._is_dir[follow_symlinks]
  3. Remove caching entirely (probably simplest)

Impact

Medium - Could cause incorrect behavior with symlinks if follow_symlinks is used with different values.

# PseudoDirEntry caching ignores follow_symlinks parameter **Priority:** Medium **Component:** fs.py **Type:** Bug ## Description The `PseudoDirEntry` class caches the results of `is_dir()`, `is_file()`, and `is_symlink()` methods but ignores the `follow_symlinks` parameter, which could return incorrect results if called with different parameter values. ## Location `curateipsum/fs.py:31-63` ## Current Code ```python def is_dir(self, follow_symlinks: bool = True) -> bool: if self._is_dir is None: self._is_dir = os.path.isdir(self.path) return self._is_dir ``` ## Problem The caching doesn't account for the `follow_symlinks` parameter. If you call: 1. `entry.is_dir(follow_symlinks=True)` → caches result 2. `entry.is_dir(follow_symlinks=False)` → returns cached result from (1), which may be wrong ## Proposed Solution Either: 1. Remove the parameter if it's not needed 2. Cache based on the parameter value: `self._is_dir[follow_symlinks]` 3. Remove caching entirely (probably simplest) ## Impact **Medium** - Could cause incorrect behavior with symlinks if follow_symlinks is used with different values.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: snegov/cura-te-ipsum#8
No description provided.