Skip to content

Delete a symlink itself, not what it points to - #42

Merged
rangoDJ merged 1 commit into
mainfrom
fix/delete-symlink-not-target
Oct 7, 2026
Merged

rangoDJ merged 1 commit into
mainfrom
fix/delete-symlink-not-target

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Fixes #41

What changed

delete_path() now looks at the entry itself before resolving it: if it's a symlink, the link is unlinked and its target is left alone. The parent directory still goes through safe_path(), so the entry can't be outside the shared folder; non-link paths take the old route (traversal still rejected, root still protected).

Testing

  • pytest: 5 new tests in tests/test_file_manager.py (link to a folder, link to a file, link pointing outside the shared folder, link in a subfolder, traversal on delete). The four symlink tests skip where symlinks can't be created, as on the Windows dev machine.
  • Ran the same scenarios on Linux (WSL, Python 3.14) against the real delete_path() with FastAPI stubbed: all pass with the fix; the original empties the linked folder and leaves the link behind.
  • Not tested in a running container.

🤖 Generated with Claude Code

delete_path() resolved the path before deleting, so deleting a symlink in
Shared Files deleted its target, and rmtree emptied a linked folder. A
symlink is now unlinked on its own; everything else is unchanged.

Fixes #41

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rangoDJ
rangoDJ merged commit 34e64b9 into main Oct 7, 2026
4 checks passed
@rangoDJ
rangoDJ deleted the fix/delete-symlink-not-target branch October 7, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting a symlink in Shared Files deletes the folder or file it points to

1 participant