-
Notifications
You must be signed in to change notification settings - Fork 854
Fix Windows Path Separator Handling in rustfs_utils #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Change SLASH_SEPARATOR from &str to char with platform-specific values ('/' for Unix, '\\' for Windows).
- Update path_join to use PathBuf::push for better cross-platform compatibility.
- Modify path_needs_clean and clean functions to handle platform separators correctly.
- Fixes "filename, directory name, or volume label syntax is incorrect" error on Windows.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF ScorecardScorecard details
Scanned Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request aims to fix Windows path separator handling issues in the rustfs utility library by replacing hardcoded Unix-style path separators ("/") with platform-specific separators. The changes introduce conditional compilation for Windows ("\") vs Unix ("/") path separators and update path manipulation functions to use these platform-specific values.
Changes:
- Introduced
SLASH_SEPARATOR(char) andSLASH_SEPARATOR_STR(str) constants with platform-specific values - Refactored
path_jointo usePathBuf::pushinstead of string concatenation - Rewrote
path_needs_cleanandcleanfunctions for cross-platform compatibility - Updated all references across the codebase from
SLASH_SEPARATORtoSLASH_SEPARATOR_STR
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/utils/src/path.rs | Core path utility changes: new constants, refactored path joining/cleaning functions, added documentation |
| rustfs/src/admin/handlers/bucket_meta.rs | Updated imports and string split operations to use SLASH_SEPARATOR_STR |
| crates/iam/src/store/object.rs | Updated path separator references in object name trimming |
| crates/ecstore/src/tier/*.rs | Updated path separator usage in S3 tier backend implementations |
| crates/ecstore/src/*.rs | Updated path separator references across storage layer files |
| crates/ecstore/src/disk/local.rs | Added dunce crate for Windows-friendly path canonicalization |
| Cargo.toml / Cargo.lock | Added dunce dependency (version 1.0.5) |
| crates/utils/Cargo.toml | Added comment to path feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…fs into fix/fix-windows-path # Conflicts: # crates/ecstore/src/disk/local.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: reatang <tangtang1251@qq.com>
Problem
On Windows systems, rustfs encounters "filename, directory name, or volume label syntax is incorrect" (os error 123) due to hardcoded Unix-style path separators (
"/") in path construction and cleaning functions. This causes invalid path strings with mixed separators (e.g.,C:\data\.rustfs.sys/tmp/.trash), leading to failures in file operations likefs::read_dirandcleanup_deleted_objects.Solution
SLASH_SEPARATORfrom&strtochar, using conditional compilation for platform-specific values ('/'on Unix,'\\'on Windows).path_jointo usePathBuf::pushinstead of string concatenation, ensuring cross-platform path handling without filesystem calls.path_needs_cleanandcleanfunctions to dynamically check and process platform-specific separators, fixing issues with..,./, and duplicate separators.clean(e.g., invalid bool-to-usize operations) and removed unused variables/warnings.Changes
crates/utils/src/path.rs: Updated constants,path_join,path_join_buf,path_needs_clean, andclean.Testing
a\b\..\ctoa\con Windows).Impact
Improves reliability on Windows without affecting Unix performance. Addresses issues in issue #1424 and similar path-related errors.
Closes #1424.