Skip to content

GH-397: Handle trailing slashes in SFTP directory operations - #960

Merged
tomaswolf merged 3 commits into
apache:masterfrom
wozhenbang2004:fix-sftp-directory-trailing-slash-397
Nov 24, 2026
Merged

tomaswolf merged 3 commits into
apache:masterfrom
wozhenbang2004:fix-sftp-directory-trailing-slash-397

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Fixes #397.

For mkdir("dir/") and rmdir("dir/"), path translation appends a dot component. A rooted filesystem keeps that component, so creating or deleting the directory fails on Unix.

Strip trailing slashes before resolving these two operations. Explicit dot and parent components remain intact, and other operations retain their trailing-slash semantics.

The SFTP regressions pass with NIO2, MINA, and Netty. They also cover missing parent directories, explicit dots, and directory symlinks. The native formatter, import sorting, and Checkstyle checks pass.

Full reactor verification was also attempted; it stops in core network and host-authentication tests in this environment before reaching SFTP.

Path translation appends a dot to mkdir and rmdir paths ending in a slash. Rooted filesystems preserve that component, causing these operations to fail on Unix.

Trim only their insignificant trailing slashes before resolving the path, preserving explicit dot and parent components and other operations.
Use NOFOLLOW_LINKS when removing the previous test directory so dangling links do not survive into the next run.

Suggested-by: @tomaswolf
Assisted-by: OpenAI ChatGPT
@tomaswolf
tomaswolf merged commit 19b0977 into apache:master Nov 24, 2026
7 checks passed
@tomaswolf

Copy link
Copy Markdown
Member

Thanks you!

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.

The RootedFileSystemProvider.resolveLocalPath() does not return normilized path any more

2 participants