Skip to content

Temporary cache cleanup follows directory symlinks and deletes target contents #2

Description

@morluto

When a compiler or post-compilation hook leaves a directory symlink in a temporary build, DiskCacheEntry cleanup follows the link and removes files from its target. Dangling symlinks are skipped, which can also leave temporary directories behind.

Reproduced at 8b3ef868705a3792cc1a14ab570b539f72fd3d94 on Linux, using disposable directories:

  1. Create an outside directory containing a sentinel file.
  2. Obtain a cache miss with DiskCache::entry.
  3. Create a directory symlink inside entry.path pointing to the outside directory.
  4. Destroy the uncommitted entry, as happens when compilation throws.
  5. The sentinel has been deleted. With a dangling link instead, the temporary entry is not fully removed.

Expected: cleanup removes the symlink itself and preserves its target. The same expectation applies when the path passed to the cleanup helper is itself a symlink.

safe_remove_all uses path-based exists and is_directory, which follow links before recursion. This reproduction uses stable paths in a trusted cache; it does not require a concurrent path replacement.

The custom walker can be retained while classifying each entry with symlink_status. Regression coverage should include directory, file, and dangling links, ordinary directories, and cleanup after a failing CUDA post-hook.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions