Skip to content

fix(io): preserve Windows drive letter in local filesystem paths#398

Merged
JingsongLi merged 1 commit into
apache:mainfrom
TheR1sing3un:fix/windows-fs-path
Jun 20, 2026
Merged

fix(io): preserve Windows drive letter in local filesystem paths#398
JingsongLi merged 1 commit into
apache:mainfrom
TheR1sing3un:fix/windows-fs-path

Conversation

@TheR1sing3un

Copy link
Copy Markdown
Member

Purpose

Linked issue: close #397

The local FileIO (fs storage) corrupts absolute Windows paths. fs_relative_path turned an absolute path into the path opendal joins onto its / root by dropping the first character — correct for POSIX (/tmp/wh -> tmp/wh), but on Windows it drops the drive letter (C:\wh -> :\wh), so every local-catalog operation fails with invalid filename (os error 123). This is why the filesystem/factory/manifest tests were gated behind #[cfg(not(windows))]. Java Paimon does not have this bug — its Path (modeled on Hadoop) keeps the drive letter and normalizes separators.

Brief change log

  • fs_relative_path now returns Cow<str>: keeps the drive specifier and only normalizes \->/ for Windows paths (opendal's PathBuf::from("/").join("C:/wh") rebuilds the real C:\wh); POSIX behavior is byte-identical.
  • Storage::create returns (Operator, Cow<str>).
  • InputFile/OutputFile store the relative path string instead of re-slicing the original (which would discard the normalization).
  • Removed the three #[cfg(not(windows))] test gates so Windows CI now exercises the local FileIO.

Tests

  • New unit tests for fs_relative_path (POSIX, file: scheme, Windows drive, mixed separators).
  • The previously Windows-gated filesystem/factory/manifest suites now run on Windows CI.

API and Format

No public API or storage-format change (the changed InputFile/OutputFile field is private).

Documentation

N/A.

The fs storage relative-path logic dropped the first character of every
absolute path to turn it into a path opendal joins onto its '/' root.
This works for POSIX ('/tmp/wh' -> 'tmp/wh') but corrupts Windows paths
('C:\\wh' -> ':\\wh'), losing the drive letter so opendal fails with
'invalid filename' on every local-catalog operation.

Keep the drive specifier for Windows paths and only normalize separators
to '/', mirroring Java Paimon's Path (modeled on Hadoop) and pypaimon's
LocalFileIO: opendal then does PathBuf::from("/").join("C:/wh"), and
because the argument carries a drive prefix Path::join rebuilds the real
C:\\wh. fs_relative_path now returns Cow so the normalized form is owned
when needed, and InputFile/OutputFile store the relative path directly
instead of re-slicing the original (which would lose the normalization).

This fixes single-file local operations on Windows; the manifest tests
(read/write only) are un-gated accordingly. Directory listing on Windows
still fails inside opendal's fs lister (it strips the operator root from
entries, which a drive-rooted path escapes), so the filesystem/factory
catalog tests stay #[cfg(not(windows))] and that rework is tracked in apache#397.

Add unit tests for fs_relative_path covering POSIX, file: scheme, Windows
drive, and mixed separators.
@TheR1sing3un TheR1sing3un force-pushed the fix/windows-fs-path branch from 4ce7e3d to 81d1a33 Compare June 19, 2026 15:21

@QuakeWang QuakeWang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The fix is well-scoped: Windows drive-rooted local paths now preserve the drive letter and normalize separators before passing paths to opendal, while non-fs storage paths stay borrowed and unchanged.

I also checked the remaining Windows directory-listing limitation; keeping those tests skipped and tracking that separately in #397 looks reasonable for this PR's scope.

@JingsongLi JingsongLi merged commit 06d6818 into apache:main Jun 20, 2026
8 checks passed
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.

Local filesystem catalog drops the drive letter on Windows (os error 123)

3 participants